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

How do I fix this script?

Asked by 10 years ago

Please make your question title relevant to your question content. It should be a one-sentence summary in question form.

Hi, I'm trying to make a script that will make the brick check if the character is a real player, then award some points, say a message, then kill you. It repeated it. I added debounce, and I looked at the ROBLOX Wiki, but none of the ROBLOX Wiki helped me. This is the whole script:

function onTouch(player)

    local actualPlayer = game.Players:GetPlayerFromCharacter(player.Parent)
    if actualPlayer then
    local buttonPressed = false
--Store whether the button is pressed in a local variable

script.Parent.Touched:connect(function(hit)
    if not buttonPressed then
    -- Is it not pressed?

        buttonPressed = true
        -- Mark it as pressed, so that other handlers don't execute
buttonPressed = false
        -- Mark it as not pressed, so other handlers can execute again
    end
end)
    actualPlayer.leaderstats.Points.Value = actualPlayer.leaderstats.Points.Value + 30
    local Win = Instance.new("Message",game.Workspace)
    Win.Text = "Somebody has got to the Finish! Well done to that person! :P"
    wait(1)
    Win:Destroy()
        if player.Parent then Humanoid.Health = 0

        end
    end
end
script.Parent.Touched:connect(onTouch)

Some of it is from the ROBLOX Wiki, and some people on IRC (Internet Relay Chat) already helped me, but that person had to go. Please help me, somebody?

1 answer

Log in to vote
0
Answered by
RedCombee 585 Moderation Voter
10 years ago

I finally found the problem.

  if player.Parent then Humanoid.Health = 0

end

You haven't set the variable "Humanoid", so this will error when the player's parent is present.

0
No. it's not that. It repeats the message, and kills me later. :| User#35 0 — 10y
Ad

Answer this question