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

Where's the problem in this script?

Asked by 9 years ago

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

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

Log in to vote
1
Answered by
1waffle1 2908 Trusted Badge of Merit Moderation Voter Community Moderator
9 years ago

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

Ad
Log in to vote
0
Answered by
xAtom_ik 574 Moderation Voter
9 years ago

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!

Answer this question