Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Why does my sword do no damage sometimes?

Asked by
Sorukan 240 Moderation Voter
5 years ago
Edited 5 years ago

This is the line of code i used and it's inside a server script

--//Variables
local tool = script.Parent
local player = tool.Parent.Parent
local char = player.Character
local hum = char:WaitForChild('Humanoid')

local debounce = false
--//Activated
tool.Activated:Connect(function()
    --//Animation
    local animation = Instance.new('Animation')
    animation.AnimationId = "rbxassetid://2690844038"
    local load = hum:LoadAnimation(animation)

    if not debounce then
    debounce = true
    load:Play()
    wait(0.5)
    debounce = false
    end
end)

local debounce2 = false
--//Touched
tool.Handle.Touched:Connect(function(hit)
    if debounce and hit and hit.Parent:FindFirstChild('Humanoid') and not debounce2 then
        debounce2 = true
        hit.Parent.Humanoid:TakeDamage(10)
        wait(0.5)
        debounce2 = false
    end
end)

Here's a gif that shows the problem. https://gyazo.com/c2df592e8e8bee75ab45651dc8772d60

0
please try clicking slower and let me know if the issues continues 95jake95 14 — 5y
0
try replacing wait(0.5) with repeat wait() until not debounce on line 29 and does the animation last for exactly 0.5 seconds? GoldAngelInDisguise 297 — 5y
0
Yes it's exactly 0.5 and it didn't work sorry. Sorukan 240 — 5y

1 answer

Log in to vote
0
Answered by 5 years ago

If your sword is made by parts and is not a mesh then make a blade(transparent) on the swords blade

But it seems like your sword is a mesh

Try printing in the function when the handle is touched if it doesn't work then your probably are not hitting them.

Try doing it filtering enabled if you can.

0
It prints sometimes and other times it doesn't just like how it was when it was dealing damage. Also the sword is already filtering enabled compatible since it's a server script inside the tool. Sorukan 240 — 5y
Ad

Answer this question