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)

4 comments

0

You can't access objects in PlayerGui from the server unless the server placed it there.

0

So, what do I do?

0

find a solution around that...?

0

How...