#i need some help to prevent loosing brain cells

1 messages · Page 1 of 1 (latest)

lapis dawn
#

alright so, i am using getpartsinpart for a sword system and i have found a solution so that the damage given is not multiple and works properly. however i need it to be like when the hitbox touches multiple people, it deals damage to all of them and not to just one of them which is my current issue. the server script is below.

local Workspace = game:GetService("Workspace")

script.Parent.RemoteEvent.OnServerEvent:Connect(function(plr, combo)
    print(combo)
    local HRP = plr.Character.HumanoidRootPart
    local hitbox = game:GetService("ReplicatedStorage").Hitbox.H1:Clone()
    
    hitbox.Parent = workspace
    hitbox.CFrame = HRP.CFrame + HRP.CFrame.LookVector * 4.5
    
    hitbox.Transparency = 0.4
    game.Debris:AddItem(hitbox, 0.5)
    
    local params = OverlapParams.new()
    params.FilterType = Enum.RaycastFilterType.Exclude
    params:AddToFilter(plr.Character, script.Parent.Handle)
    
    local hit = Workspace:GetPartsInPart(hitbox, params)
    local buff
    for i, v in pairs(hit) do
        
            local hum = v.Parent:FindFirstChild("Humanoid")
            if hum then
                if buff ~= hum.Parent.Name then
                    hum:TakeDamage(10)
                    buff = hum.Parent.Name
                end
                
                
                
            end
        
        
    end
    
    
end)
junior halo
#

which it seems like they are already getting hit multiple times so that filter would be good either way

lapis dawn
#

so i like insert it to a table?

junior halo
#

bunch of ways to do it but i'd think wasHit={} ... if not wasHit[humanoid] then wasHit[humanoid]=true doDamage() etc

lapis dawn
#

alright i will just go with get parts in part as i js realized i dont want the hitbox to live for 0.5

#

thank you

junior halo
# lapis dawn thank you

keep it up, and keep learning how to problem solve stuff like this .. without me giving you an exact solution .. and you'll be a fully fledged scripter in no time fingerguns

lapis dawn
junior halo
# lapis dawn so i like insert it to a table?

your first thought was right, you could table.insert then if not table.find(washit,humanoid) but i like the dictionary method since you avoid a table.find being there for no good reason

lapis dawn
#
local tool = script.Parent
local combo = 0
local debounce = false
local plr = game.Players.LocalPlayer


local animations = {
    [1] = "rbxassetid://119089449350873",
    [2] = "rbxassetid://119089449350873",
    [3] = "rbxassetid://119089449350873"
}


tool.Activated:Connect(function()
    
    
    if debounce == false then
        if combo < 4  then
            combo += 1
        else
            combo = 1
        end
        local animator = plr.Character:WaitForChild("Humanoid"):WaitForChild("Animator")
        local ani = Instance.new("Animation")
        ani.AnimationId = animations[combo]
        
        local track = animator:LoadAnimation(ani)
        track:Play() 
        
        
        script.Parent.RemoteEvent:FireServer(combo)
        debounce = true    
        wait(0.5)
        debounce = false
    end
    
end)
#

so first of all, the animations dont play

#

and when the combo like gets to 3, it breaks and gives an error saying the animation is nil

#

when its like at the 4th one, it gives an error but it does reset

#

oh my god

dim ridgeBOT
#

studio** You are now Level 3! **studio

lapis dawn
#

am dumb

#

the animation was r6 but the characther was r15

#

😭

azure loom