This line is giving me an infinite yield error. I don’t know why this is happening because I’ve used this same line of code in another project and it didn’t give me any trouble. (It’s in a local script)
local Cost = 100
local player = game:GetService("Players")
local playerStats = player:WaitForChild("leaderstats")
local playerGold = playerStats:WaitForChild("Gold")
local gui = game.Players.LocalPlayer:WaitForChild("PlayerGui"):WaitForChild("ScreenGui")
local Owned = gui.Shop.Stats.Frame.LongStick.Owned
script.Parent.MouseButton1Click:Connect(function()
if playerGold.Value >= Cost and Owned.Value == false then
playerGold.Value = playerGold.Value - Cost
Owned.Value = true
end
end)
19:01:28.838 - Infinite yield possible on ‘Players:WaitForChild(“leaderstats”)’