im very started and trying to make a game maybe im too stupid but there also nothing in the output pls help
local Player = game.Players.LocalPlayer
local Money = Player.leaderstats.Money
local Multi = Player.Multi
local ReplicatedStorage = game.ReplicatedStorage
local Remotes = ReplicatedStorage.Remotes
local Remote = Remotes.DoubleMoneyGain
local screenGUI = script.Parent
local StatsHolder = screenGUI.GuiHolder.StatsHolder
local UpgradesHolder = screenGUI.GuiHolder.UpgradesHolder
local DoubleMoneyGainButton = UpgradesHolder.DoubleMoney.UpgradeButton
local function DoubleMoneyGain()
local NumberOfUpgrades = DoubleMoneyGainButton.NumberOfUpgrades
if NumberOfUpgrades == 0 then
DoubleMoneyGainButton.MouseButton1Click:Connect(function()
Money.Value -= 5
Multi.Value *= 2
NumberOfUpgrades.Value += 1
Remote:FireServer()
end)
end
end
Something that might help is using the WaitForChild() method on the GUI variables. The children of the ScreenGUI may not be loaded in yet when you play-test the game, so when the button is clicked, your function won’t fire. You could also try adding a task.wait(5) at the top of your script.
local Player = game.Players.LocalPlayer
local Money = Player.leaderstats.Money
local Multi = Player.Multi
local screenGUI = script:WaitForChild("ScreenGui")
local GuiHolder = screenGUI:WaitForChild("GuiHolder")
local UpgradesHolder = GuiHolder.UpgraderesHolder
local StatsHolder = GuiHolder.StatsHolder
local DoubleMoneyGainButton = UpgradesHolder.DoubleMoney.UpgradeButton
local function DoubleMoneyGain()
local NumberOfUpgrades = DoubleMoneyGainButton.NumberOfUpgrades
if NumberOfUpgrades == 0 then
Money.Value -= 5
Multi.Value *= 2
NumberOfUpgrades.Value += 1
end
end
DoubleMoneyGainButton.MouseButton1Click:Connect(function()
DoubleMoneyGain()
end)
Why are you trying to access the ScreenGUI like it’s a child of the script? By looking at the hierarchy, this will error. It should be equal to script.Parent.
Could you try this ?
Also, changing the values in client side will make it “invisible” in server side, so nothing will be saved and nothing will apply to your real stats.
local PlayerService = game:GetService("Players")
local Player = PlayerService.LocalPlayer
local Multi = Player:WaitForChild("Multi", 300)
local Leaderstats = Player:WaitForChild("leaderstats", 300)
local Money = Leaderstats and Leaderstats:WaitForChild("Money", 30)
local screenGUI = script.Parent
local GuiHolder = screenGUI:WaitForChild("GuiHolder", 30)
local UpgradesHolder = GuiHolder and GuiHolder:WaitForChild("UpgraderesHolder", 30)
local StatsHolder = GuiHolder and GuiHolder:WaitForChild("StatsHolder", 30)
local DoubleMoneyGainButton = UpgradesHolder:FindFirstChild("UpgradeButton", true)
local NumberOfUpgrades = DoubleMoneyGainButton:FindFirstChild("NumberOfUpgrades")
local function DoubleMoneyGain()
if NumberOfUpgrades.Value == 0 then
Money.Value -= 5
Multi.Value *= 2
NumberOfUpgrades.Value += 1
end
end
DoubleMoneyGainButton.MouseButton1Click:Connect(DoubleMoneyGain)