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

How do I fix this script?

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

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.

1 comment

0

No. it's not that. It repeats the message, and kills me later. :|

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