I have an animation with an Animation Event
, and when it reaches that point, I want it to check if anyone is touching a certain object. If anyone is touching that object during the event, it’ll damage you.
The issue is, even with a debounce, it damages the player way more than it should.
I’ve tried setting the CanTouch
on the object to false after it damages the player, but that hasn’t even worked. Sorry if this doesn’t make sense, I’m very tired.
This is my code for it
local indb = true
swing1:GetMarkerReachedSignal("Contact"):Connect(function()
blade.Touched:Connect(function(hit)
if hit.Name == "HumanoidRootPart" and indb then
indb = false
blade.CanTouch = false
hit.Parent.Humanoid:TakeDamage(50)
hrp.HitPlayer:Play()
print("hit player")
end
end)
hrp.HitGround:Play()
end)
I feel like there’s another way to do this, but if there is, I have no idea what that would be.
In summary, I want this object to only damage the player during the animation event, and only once. After that I want it to not be able to hurt the player until the animation replays and it reaches the event again.