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

Cant Make A LeaderStat Value Change?

I have made 3 leaderstats like this:

game.Players.PlayerAdded:Connect(function(Player) local Stats = Instance.new('Folder',Player) Stats.Name = 'leaderstats'

local Robux = Instance.new('IntValue',Stats)
Robux.Name = 'Robux' 
Robux.Value = 0  

local Amount = Instance.new('IntValue',Stats)
Amount.Name = 'Amount'
Amount.Value = 1

end)

the script is in ServerScriptService. I have made a GUI button with this local script:

local Player = game.Players.LocalPlayer local PlayerStats = Player:WaitForChild('leaderstats'):WaitForChild('Robux') local Amount = Player:WaitForChild('leaderstats'):WaitForChild('Amount')

script.Parent.MouseButton1Click:Connect(function() print("Clicked") PlayerStats.Value = PlayerStats.Value + Amount end)

I want to make so i can change how much players will get pr click like when you buy something in a shop.

Pls consider helpinh thx :)

2 comments

0

Note: Select the part of the text that's your code and then click the lua button ( You can edit this question by clicking on the button right under the comments )

0

But i want the value only to change at the Client not the Server

2 answers

You have to use Normal Script. With local scripts, you cant change values without remote controls.

1 comment

0

Actually can, it will just not be replicated to others

You just made some simple errors in your script.

Local script:

local Player = game.Players.LocalPlayer

local PlayerStats = Player:WaitForChild("leaderstats"):FindFirstChild("Robux")

local Amount = Player:WaitForChild("leaderstats"):FindFirstChild("Amount")

local RemoteEvent = ReplicatedStorage:WaitForChild("RemoteEvent")
 
script.Parent.MouseButton1Click:Connect(function() 

PlayerStats.Value = PlayerStats.Value + 1
Amount.Value = Amount.Value + 1

end)

If a player clicks the button, it increases both the values by 1 and other player's won't see the change since it's a local script and it doesn't get replicated to the server.

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