I use RemoteEvents for value manipulation, like using GUIs to add values from the server.
I have this script that serves as the “Core” script of my game, this is just a bit of it. Most of the contents of the script is just OnServerEvents and nothing else.
-- QuickAdEvent event
game.ReplicatedStorage.Misc.QuickAdEvent.OnServerEvent:Connect(function(player)
player.leaderstats.Cash.Value = player.leaderstats.Cash.Value + (player.leaderstats.Rebirths.Value + 1)
end)
-- MBAdd event
game.ReplicatedStorage.Misc.MBAdd.OnServerEvent:Connect(function(player)
local a = player.stats.mb.Value + 1
local price = a * 1000
if player.leaderstats.Cash.Value >= price then
player.stats.mb.Value = player.stats.mb.Value + 1
player.leaderstats.Cash.Value = player.leaderstats.Cash.Value - price
end
end)
-- MBSub event
game.ReplicatedStorage.Misc.MBSub.OnServerEvent:Connect(function(player)
if player.stats.mb.Value >= 1 then
player.stats.mb.Value = player.stats.mb.Value - 1
player.leaderstats.Cash.Value = player.leaderstats.Cash.Value + (player.stats.mb.Value * 100)
end
end)