Ok so, I created this script for a sword game. It's basically a rehaul of that one classic Roblox sword. There's currently a bug where you can stack damage. Basically, if you have damaged the humanoid once, then use the sword 5 times, the moment the sword touches the model with the humanoid, it will deal 500 damage. The script is below.
game.ReplicatedStorage.SwordHit.OnServerInvoke = function(player)
local character = player.Character
if character then
local hum = character:FindFirstChild("Humanoid")
local anim = hum:LoadAnimation(script.Anim)
local arm = character:FindFirstChild("Right Arm")
local humanoidRootPart = character:FindFirstChild("HumanoidRootPart")
local sword = character:FindFirstChild("Sword") -- Sword is part of the StarterCharacter
local strail = sword:FindFirstChild("SwordTrail")
local dmg = false
strail.Enabled = true
anim:Play()
sword.SwordSwing:Play()
wait(0.35)
strail.Enabled = false
sword.Touched:Connect(function(hit)
if hit.Parent:IsA("Model") then
if dmg == true then return end
dmg = true
local hum = hit.Parent:FindFirstChild("Humanoid")
if (hum ~= nil) then
hum.Health = hum.Health - 100
sword.SwordHit:Play()
end
end
end)
end
end
Any help would be appreciated, Thanks.
