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

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

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

Use remote event.

Script 1

Example = 0
RemoteEvent:fireserver(Example)

Script 2

RemoteEvent.onServerEvent:connect(function(Example)
Point = Example

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.

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