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

Where's the problem in this script?

I've made this script but can't find where the problem is. This script will basically add points to the player's NumberValue in a ScreenGui once the Brick with script in it has been touched. And will the "local points" add points to just the player who touched it?

part = script.Parent

part.OnTouched:connect(function(Touched)
	local points = script.Parent.Parent.Parent.StarterGui.Points.PointLabel.PointValue
	points.Value = points.Value + 10
end)

(Don't know if the script showed up correctly)

2 answers

OnTouched is not the name of an event; part.Touched:connect is.

No, local will not make it to only the player who touches.

The Problems

OnTouched is no such event, change it to Touched. You are adding points to the wrong gui, you are giving points when people respawn.

Script:

Here is a fixed version of the script:

part = script.Parent

part.OnTouched:connect(function(hit) 
	if game.Players:FindFirstChild(hit.Parent.Name) ~= nil then
		game.Players[hit.Parent.Name].PlayerGui.Points.PointLabel.PointValue.Value = game.Players[hit.Parent.Name].PlayerGui.Points.PointLabel.PointValue.Value + 10
	end
end)

I hope this helped you out!

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