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

How do I change an IntValue's value when inside a player?

Asked by 4 years ago
Edited 4 years ago

I made a StarterCharacter, with an IntValue inside of the character.

I want the IntValue's value in the character to go up by two when I touch a part.

script.Parent.Touched:Connect(function(plr)

    plr.LocalPlayer.Character.Value.Value = plr.LocalPlayer.Character.Value.Value + 2 --Isn't working, and not giving an error.

    print("plus 2") --Isn't printing due to line 3 not working

end)
0
try plr.Parent instead of plr.LocalPlayer.Character Donut792 216 — 4y
0
The code won't run, because it is in workspace! BashGuy10 384 — 4y

1 answer

Log in to vote
1
Answered by
BashGuy10 384 Moderation Voter
4 years ago
Edited 4 years ago

Like Donut792 said, use plr.Parent

CHANGE YOUR SCRIPT TO A SERVER SCRIPT!

script.Parent.Touched:Connect(function(plr)

    plr.Parent.Value.Value = plr.Parent.Character.Value.Value + 2 --Isn't working, and not giving an error.

    print("plus 2") --Isn't printing due to line 3 not working

end)
Ad

Answer this question