This is my first time using luau coding, so I'm learning to code. For my first project, I wanted the spawn to kill players and then wait 10 seconds before being able to kill them again. But I don't know where my mistake is.
my code is :
function killPLayer(SpawnLocation)
local character = SpawnLocation.Parent
if character and character:IsA("Model") then
local humanoid = character:FindFirstChildOfClass("Humanoid")
if humanoid then
humanoid:TakeDamage(humanoid.MaxHealth)
end
end
end
script.Parent.Touched:Connect(killPLayer)
local killblock = false
script.Parent.TouchEnded:Connect(function(hit)
local character = hit.Parent
local humanoid = character:FindFirstChildOfClass("Humanoid")
if not humanoid and humanoid.Health <= 0 then return end
if killblock then return end
killblock = true
humanoid:TakeDamage(humanoid.MaxHealth)
task.delay(10, function()
killblock = false
end)
end)
I'm learning to code!
Thanks for the help!
