Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 9 years ago
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

Log in to vote
0
Answered by
Shawnyg 4330 Trusted Badge of Merit Snack Break Moderation Voter Community Moderator
9 years ago

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)
Ad

Answer this question