✓ Accepted answer
First of:
1.): Use the player's PlayerGui, not StarterGui.:
What the player sees on their screen are descendants of their PlayerGui. StarterGui holds all guiObjects and other instances that'll be cloned to the player's PlayerGui upon joining.
2.): Don't call the function that's to be connected to an event:
Connections need a function value that isn't supposed to be fired there
What it's supposed to be:
RemoteEvent.OnServerEvent:Connect(RemoteFunction)
Anyways, what you're supposed to do is handle the event from the server, and add a parameter for the amount to be added. Why this you may ask, because the server can't access each client's descendants of their PlayerGui, so we can't get the amount to be added.
Server Code:
local Remote = Instance.new('RemoteEvent')
Remote.Name = 'Updates'
Remote.Parent = game.ReplicatedStorage
function RemoteFunction(player, amount)
player.leaderstats['Crate Bux'].Value = player.leaderstats['Crate Bux'].Value + amount
end
Remote.OnServerEvent:Connect(RemoteFunction)
Then, we're going to make the client code to fire the event to update the 'Crate Bux' currency
local Remote = game.ReplicatedStorage:WaitForChild('Updates')
local player = game.Players.LocalPlayer
wait()
local amount = player.PlayerGui.MainGui.Buttons['CLICK FOR CRATE BUX'].amount
Remote:FireServer(amount.Value)
2 comments
You're doing it all wrong
How can I fix it?