Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

does this code function correctly as a trap/deals damage?

script.Parent.Touched:Connect(function(hit)
local character = hit.Parent
local human = character:FindFirstChild("Humanoid")
local player = game.Players:GetPlayerFromCharacter(character)
if player and human.Health > 0  then
human.Sit = true
end
end

2 comments

1

What?

0

you don't need player, you could just use " If Human and Human.Health > 0 then Human.Health -= damage

2 answers

✓ Accepted answer
script.Parent.Touched:Connect(function(hit)
	local character = hit.Parent
	local human = character:FindFirstChild("Humanoid")
	if human and human.Health > 0  then
		human.Health -= damage
	end
end

1 comment

0

thanks it works! :D

This discussion is preserved as it was. New answers, comments, and votes are closed.