Why is it now working this is my script PLS halp ME
local tool = script.Parent local Settings = tool:WaitForChild("Settings") local Strength = Settings.Strength local Player = game.Players.localPlayer local PlayerUI = Player:WaitForChild("PlayerGui").PlayerUI local ReplicatedStorage = game:GetService("ReplicatedStorage") local RemoteEvents = ReplicatedStorage.RemoteEvents local CoinClicked = RemoteEvents.CoinClicked local Debounce = false tool.Activated:Connect(function() if Player.PlayerStats.CurrentValue.Value < Player.PlayerStats.Storage.Value then if Debounce == false then Debounce = true CoinClicked:FireServer(Strength.Value) wait(0.25) Debounce = false end else -- StorageFull Code end end)
I'm assuming that when the script is running, at line 8, it's checking for PlayerUI
before it has existed at that time (By that I mean before the PlayerUI
hasn't been cloned to PlayerGui
at the moment the script was running). To fix this, just add another :WaitForChild
for PlayerUI
like this:
local PlayerUI = Player:WaitForChild("PlayerGui"):WaitForChild("PlayerUI")