I want to give a player some cash, but if I do it in localscript saving doesn't work, because Changed events don't work when localscript performs it.
I need a remote event for increasing player cash through Script.
Fire should look like:
game.ReplicatedStorage.AddCash:FireServer(5)
so I want to increase localplayer's cash by 5.
Please send me, how to make it in server script.
Well, I do agree with other options but I think you can use it much better. As I know there is many tutorials and I watches some and it shows how to do it. Well, you can type on youtube your fraze + how to do it or just on dev forums. Also try to do it on other script (change local to script normal one). Hope I helped.
local remote = game.ReplicatedStorage.Remote remote:OnServerEvent:Connect(function(player) player.leaderstats.Cash.Value = player.leaderstats.Cash.Value + 5 end)
(Tell me if this helped! Accept it if it's the answer you needed!)
To add the player's cash, setup the server side of the RemoteEvent as such:
--Player service and the remote. local PlayerService = game.GetService("Players") local AddCash = game:GetService("ReplicatedStorage").AddCash --Listen for events from the client. The player argument is there by default. AddCash.OnServerEvent:Connect(function (player, addedcash) --Location of the cash. local cash = PlayerService.player.Cash cash.Value = cash.Value + addedcash end)