#hitbox spawning where player last was before death

1 messages · Page 1 of 1 (latest)

bold willow
#

im making a fighting game and for some reason i have this bug where if you die and continue to play the game as normal, hitboxes will now spawn where your player last was before you died. i have nothing that saves the position of the player upon death so i have no clue as to why this is happening

#

function serverUtilities:hitbox(plr,move,additionalParam)
    
    --warn("move:",move)
    
    local character = plr.Character
    local humanoid = character:FindFirstChildOfClass("Humanoid")
    local hrp = character:FindFirstChild("HumanoidRootPart")
    
    local tempData = playerTemporalIndex:FindFirstChild(plr.Name .. "tempdata")
    
    local buildFolder = tempData:FindFirstChild("build")
    
    local playerClass = buildFolder:FindFirstChild("class").Value
    
    local moveIndex =  classes[playerClass]["moves"][move]
    
    local hitbox = Instance.new("Part")
    hitbox.Parent = game.Workspace
    
    if additionalParam ~= nil and additionalParam >= 1 then
        moveIndex = classes[playerClass]["moves"][move][additionalParam]
    end
    
    hitbox.Size = moveIndex["hitbox"]
    
    hitbox.Anchored = true
    hitbox.Transparency = .7
    hitbox.CanCollide = false
    
    local playerSettings = game.ReplicatedStorage.playerTemporal:FindFirstChild(plr.Name .. "tempdata"):FindFirstChild("settings")
    local hasClientPriority = playerSettings:FindFirstChild("clientHitboxPriority")
    
    if hasClientPriority then
        local clientHrp = runtimeComms:InvokeClient(plr,"gethrp")
        hitbox.CFrame = clientHrp * moveIndex["hrpdistance"]
    else
        --or if ping too high
        hitbox.CFrame = hrp.CFame * moveIndex["hrpdistance"]
    end

    
    local ar = region3mod.FromPart(hitbox)
    local result = region3mod.Cast(ar,character)
    
    local playersHit = {}
    
    for _,item in pairs (result) do
        if table.find(gameInfo.bodyparts,item.Name) and item.Parent:FindFirstChildOfClass("Humanoid") and not table.find(playersHit,item.Parent) then
            --print("detected")
            local enemyHumanoid = item.Parent:FindFirstChildOfClass("Humanoid")
            table.insert(playersHit,item.Parent)
            
            --make sure to check if player has iframes or something
            serverUtilities:damage(plr,enemyHumanoid,move,additionalParam)
            
            
            
            
        end
    end
    
    game.Debris:AddItem(hitbox,.03)
    
    return hitbox,result
end
#

i doubt its the hasClientPriority thingy because

  1. it's defaulted to false (and also is false in the video)
  2. it would literally ask the client where the humanoidrootpart is.
#

it could be the ragdoll but i'm not sure

update: it is not the ragdoll.

split vectorBOT
#

studio** You are now Level 4! **studio

bold willow
#

thx for responding, unfortunately it still spawns where the player last was when they died

sonic oar
#

Damn

bold willow
#

still no luck 😭

sonic oar
bold willow
#

no errors in output 💔

sonic oar
#

Wait a minute

#

Cfame

#

Nvm

bold willow
#

i fixed the typo but

#

still nothing

sonic oar
#

Where did you put the script?

#

Uh

bold willow
#

the one u sent? it's in a module script called serverUtilities, which is called by a server script called actionHandler

animationTrack:GetMarkerReachedSignal("hit"):Connect(function(param)
        local number = tonumber(param)
        if param == 0 then param = nil end
        
        serverUtilities:hitbox(plr,move,number)
    end)
split vectorBOT
#

studio** You are now Level 2! **studio

bold willow
#

right now i'm running out of ideas so i'm lowkey just doing stupid stuff like this, trying to get it to work

sonic oar
# bold willow right now i'm running out of ideas so i'm lowkey just doing stupid stuff like th...

local Players = game:GetService("Players")
local RunService = game:GetService("RunService")

local function spawnHitbox(plr)
local char = plr.Character
if not char then return end

local hrp = char:FindFirstChild("HumanoidRootPart")
if not hrp then
    warn("No HRP)
    return
end

local hitbox = Instance.new("Part")
hitbox.Size = Vector3.new(5, 5, 5)
hitbox.Anchored = true
hitbox.CanCollide = false
hitbox.Transparency = 0.5
hitbox.BrickColor = BrickColor.Red()
hitbox.CFrame = hrp.CFrame * CFrame.new(0, 0, -5)
hitbox.Parent = workspace

game.Debris:AddItem(hitbox, 0.5)

end

Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(character)
wait(1)

    while character and character.Parent == workspace do
        spawnHitbox(player)
        wait(1)
    end
end)

end)
Put this inside a new script inside of server script service

bold willow
#

alright

#

weirdly enough that does work as intended, i reset and it's still spawning in front of me

sonic oar
#

Nice

bold willow
#

oh my god.

#

i think i found it.

#

hold on if this works i'm gonna get mad

#

it worked.

sonic oar
#

Didn't it work before

bold willow
#

no like i just fixed the entire thing

#

turns out

#

it's this specific line

#

it was checking if it existed at all

#

not it's actual value

#

@sonic oar thank you so much for your help though 😭 🙏, i'm sorry that it was something so goofy like this

sonic oar