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

how do I change the value of points from another script?

Asked by
KNOSIS 8
5 years ago
local function onPlayerJoin(player)
    local leaderstats = Instance.new("Folder")
    leaderstats.Name = "Leaderstats"
    leaderstats.Parent = player

    local points = Instance.new("IntValue")
    points.Name = "Points"
    points.Parent = leaderstats
    points.Value = 0
end

game.Players.PlayerAdded:Connect(onPlayerJoin)

2 answers

Log in to vote
0
Answered by 5 years ago

Use remote event.

Script 1

Example = 0
RemoteEvent:fireserver(Example)

Script 2

RemoteEvent.onServerEvent:connect(function(Example)
Point = Example
Ad
Log in to vote
0
Answered by
DanzLua 2879 Moderation Voter Community Moderator
5 years ago
Edited 5 years ago

You have to navigate to it in that other script.

player.leaderstats.Points.Value = player.leaderstats.Points.Value+10

Of course you would have to figure out the best way to set player.

If you are in a localscript you could use

player=game.Players.LocalPlayer

But you would only be able to read from there, in which you would use remoteevents to change it from the server.

some events return player too such as the event your using for onPlayerJoin.

Answer this question