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

my TextButton that is suppose to kill but it won't work can u fix my problem?

game.ReplicatedStorage.RemoteEvent.OnServerEvent:Connect(function(player) local char = player.Character local hum = char:WaitForChild("Humanoid")

hum.Health = 0 end)

2 comments

0

Use a close block plz next time

0

and maybe an output this should work

2 answers

✓ Accepted answer

Try this out.

game.ReplicatedStorage:WaitForChild("RemoteEvent").OnServerEvent:Connect(function(player)
	local PlayerCharacter = player.Character
	
	if not PlayerCharacter then
		repeat wait() until PlayerCharacter
		local PlayerHumanoid = PlayerCharacter.Humanoid
		PlayerHumanoid.Health = 0
	else
		local PlayerHumanoid = PlayerCharacter.Humanoid
		PlayerHumanoid.Health = 0
	end
end)

4 comments

0

-1. No explanation was given. And for polling.

0

@programmerHere ok? lol

0

my laptop where i normaly make games on is charging. i will try this when its charged

0

won't work ;-;

Your script:


game.ReplicatedStorage.RemoteEvent.OnServerEvent:Connect(function(player) -- Always use waitforchild
local char = player.Character 
local hum = char:WaitForChild("Humanoid")

hum.Health = 0 
end)

Edited Script:


game.ReplicatedStorage:WaitForChild("RemoteEvent").OnServerEvent:Connect(function(player) 
    local char = player.Character
     local hum = char.WaitForChild("Humanoid")
if hum then
wait()
     hum.Health = 0
end
end)

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