local tool = script.Parent local Settings = tool:WaitForChild("Settings") local Strength = Settings:WaitForChild("Strength") local Player = game.Players.LocalPlayer:WaitForChild("PlayerStats") local PlayerUI = Player:WaitForChild("PlayerGui").PlayerUI local ReplicatedStorage = game:GetService("ReplicatedStorage") local RemoteEvents = ReplicatedStorage:WaitForChild("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.20) Debounce = false end else if PlayerUI.StorageFull.Visible == false then if Debounce == false then Debounce = true PlayerUI.StorageFull.Visible = true wait(0.5) Debounce = false end end end end)
Don't worry, infinite yields arent a problem, it's just your script, it is stuck on that line and always trying infinitly to find the given child which is not loaded yet or might not be a thing at all.
To prevent this you can use WaitForChild
's second argument, which the wait time, and it'll probarly remove the yielding.
local Player = game.Players.LocalPlayer:WaitForChild("PlayerStats", 1) --1 is just an example put whatever you want