Hi, I'm trying to make an ability for a sword which does a lot of damage in one hit. It does the damage, but it keeps damaging the opponent even when you're just holding the sword over them. Ive tried making it wait and set the takedamage script to 0 but it still won't work. Help would be much appreciated!
here is the script in server script service which gets activated once a remote event is fired:
game.ReplicatedStorage.Bat.OnServerEvent:Connect(function(player)
local char = player.Character
local bat = char:FindFirstChild("Bat")
wait(1.2)
bat.Handle.Bonk:Play()
bat.Handle.bat_hit:Play()
bat.Handle.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") then
if hit.Parent.Name ~= player.Name then
hit.Parent.Humanoid:TakeDamage(1.5)
end
end
end)
wait(.5)
bat.Handle.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") then
if hit.Parent.Name ~= player.Name then
hit.Parent.Humanoid:TakeDamage(0)
end
end
end)
end)

2 comments
Thank you so much! I really cant thank you enough for this. I've been waiting for so long to get an answer. Thank you!
Any time! :D