Is that the whole script? It looks like you missed some code at the top.
local function onTouched(Obj) --This line was missing
local h = Obj.Parent:FindFirstChild("Humanoid")
if h then
h.Health = 0
end
end
script.Parent.Touched:Connect(onTouched)
script.Parent.Touched:connect(function(hit)
if hit and hit.Parent and hit.Parent:FindFirstChild("Humanoid") then
hit.Parent.Humanoid.Health = 0
end
end)
This topic is already solved but I just wanna put this short script out there.
script.Parent.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") then --if the script finds a humanoid inside hit.Parent then it will run the next line of code
hit.Parent:BreakJoints() --also kills the player
end
end)