if script.Parent.CanDamage.Value == true then
if not touch.Parent:FindFirstChild("Humanoid") then return end
script.Parent.CanDamage.Value = false
touch.Parent.Humanoid:TakeDamage(plr.leaderstats.Power.Value)
if touch.Parent.Humanoid.Health < 1 then
local plr = game.Players:GetPlayerFromCharacter(script.Parent.Parent)
plr.leaderstats.Kills.Value = plr.leaderstats.Kills.Value + 1
end
wait(1)
script.Parent.CanDamage.Value = true
end
Touched needs to be a event, so basically touched:connect(function), for events like this, you don’t need to use If statments
local CanDamage = script.Parent.CanDamage
if script.Parent.CanDamage.Value == true then
script.Parent.Touched:Connect(function(hit)
if not hit.Parent:FindFirstChild("Humanoid") then
script.Parent.CanDamage.Value = false
script.Parent.Touched:Connect(function(hit)
local humanoid = hit.Parent
if humanoid then
humanoid:TakeDamage(10)
if humanoid.Health < 1 then
local plr = game.Players:GetPlayerFromCharacter(hit.Parent)
plr.leaderstats.Kills.Value = plr.leaderstats.Kills.Value + 1
end
wait(1)
end
script.Parent.CanDamage.Value = true
end)
end
end)
end
This is probably not going to work, but your code around this code, it’s supposed to give you an idea, this code will only work with instances, i.e parts etc.