So, I am trying to make a button so when you click on it you get money, I also created an Upgrades button, But when I upgrade the amount you get it still adds the old amount? So, how do I update the remote event so when the amount I get increases it adds the new amount instead of the old one

Script:

local amount = game.StarterGui.MainGui.Buttons["CLICK for CRATE BUX"].amount
local RemoteEvent = Instance.new("RemoteEvent")
RemoteEvent.Parent = game.ReplicatedStorage
RemoteEvent.Name = "Updates"
local function FireEvent(player)
	player.leaderstats['Crate Bux'].Value = player.leaderstats['Crate Bux'].Value + amount.Value
end	
RemoteEvent.OnServerEvent:Connect(FireEvent)

local script:

local amount = script.Parent.amount

	script.Parent.MouseButton1Click:Connect(function(click)	
	 game.ReplicatedStorage:WaitForChild('Updates'):FireServer()

end)

while wait(0.1)do
	script.Parent.Text = "Click for "..amount.Value.."CB"
end

Upgrade script:

local amount = game.StarterGui.MainGui.Buttons["CLICK for CRATE BUX"].amount
local CrateBux = game.Players.LocalPlayer.leaderstats['Crate Bux']
local Cost = script.Parent.Parent.Parent.Parent.Cost
--Upgrade
 script.Parent.MouseButton1Click:Connect(function()
  if CrateBux.Value >= Cost.Value then 
	amount.Value = amount.Value + 30
	CrateBux.Value = CrateBux.Value - Cost.Value
	Cost.Value = Cost.Value * 2
	
end
end)
--Changing text
	while wait(0.1)do
	script.Parent.Text = "Upgrade for ["..Cost.Value.."]"
end

2 comments

0

Do you mean adding a remote event to your upgrade button script?

0

Yeah kinda