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 :)
You have to use Normal Script. With local scripts, you cant change values without remote controls.
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.