I use remote events to connect the scripts
script:
local RemoteEvent = Instance.new('RemoteEvent') RemoteEvent.Parent = game.ReplicatedStorage RemoteEvent.Name = "Increase CB" function Increase(player) player.leaderstats['Crate Bux'].Value = player.leaderstats['Crate Bux'].Value + player.PlayerGui.MainGui.Buttons['CLICK for CRATE BUX'].amount.Value end RemoteEvent.OnServerEvent:Connect(Increase)
localscript :
local Remote = game.ReplicatedStorage:FindFirstChild('Increase CB') local player = game.Players.LocalPlayer local Gui = player.PlayerGui local amount = player.PlayerGui.MainGui.Buttons['CLICK for CRATE BUX'].amount local CrateBux = player.leaderstats['Crate Bux'] wait() Gui.MainGui.Buttons['CLICK for CRATE BUX'].MouseButton1Click:Connect(function() Remote:FireServer() end)