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

Ideas on how to make this not create multiple of its self?

local KillBrick= script.Parent
function steppedOn(part) 
local parent = part.Parent
if game.Players:GetPlayerFromCharacter(parent) then
      parent.Humanoid.Health = 0
      hint = Instance.new('Hint', Workspace) 
      hint.Text = "You just got Bloxxed!"
      wait(5)
      hint:Destroy()
   end
end
KillBrick.Touched:connect(steppedOn)

It works, its just that it creates more then one then only deletes one of them and then stops. Any advice is helpful :)

1 answer

✓ Accepted answer

You need to check if there already is a Message in Workspace! Another way to kill a player is by breaking the joints of their character. You could also use the Debris Service to wait a specific time, then remove it!:

KillBrick = script.Parent -- No reason to set this local, since it's not in a function

KillBrick.Touched:connect(function(hit)
	if hit.Parent and game.Players:GetPlayerFromCharacter(hit.Parent) and not game.Workspace:findFirstChild("Message") then -- You need to check if there is a parent!
		hit.Parent:BreakJoints()
		local hint = Instance.new('Hint')
		hint.Text = "You just got Bloxxed!"
		hint.Parent = game.Workspace
		game:GetService("Debris"):AddItem(hint, 5)
	end
end)

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