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

If you add a IntValue inside LocalPlayer, how do you change it in another script?

Hello, i'm new to scripting. So I added an IntValue inside game.Player.LocalPlayer, how do I change it from 0 to 1? If you need the code i will send it

2 comments

0

Always assume that we need the code

0

Since you're using LocalPlayer it has to be a LocalScript. And everything made from a LocalScript will only affect that specific player. If you add something with a LocalScript, the Server won't be able to see it and therefore you can not change it from a Server Script or a LocalScript associated with another player

1 answer

Depends on your situation. If this value is only needed to be seen by you, The client , you can just change it like this:

Players = game:GetService("Players") -- The players service
Player = Players.LocalPlayer -- Your local player
IntValue = Player:WaitForChild(-YOUR VALUE'S NAME-) -- Waits for your value to be added
IntValue.Value = 1 -- Changes it to 1
print("Your value is"..IntValue.Value") -- Prints it's value

If you want to change it for everyone however, The server , you might want to understand how to use RemoveEvents or PlayerAdded, since The server can't distinct which player you are ( unless you parent the script to your player ).

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