Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

infinite yield on WaitForChild("PlayerStats")?

Asked by 6 years ago
Edited 6 years ago
01local tool = script.Parent
02 
03local Settings = tool:WaitForChild("Settings")
04local Strength = Settings:WaitForChild("Strength")
05 
06local Player = game.Players.LocalPlayer:WaitForChild("PlayerStats")
07local PlayerUI = Player:WaitForChild("PlayerGui").PlayerUI
08 
09local ReplicatedStorage = game:GetService("ReplicatedStorage")
10local RemoteEvents = ReplicatedStorage:WaitForChild("RemoteEvents")
11local CoinClicked = RemoteEvents.CoinClicked
12 
13local Debounce = false
14 
15tool.Activated:Connect(function()
View all 33 lines...

1 answer

Log in to vote
0
Answered by
starmaq 1290 Moderation Voter
6 years ago
Edited 6 years ago

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.

1local Player = game.Players.LocalPlayer:WaitForChild("PlayerStats", 1)
2--1 is just an example put whatever you want
0
also how do i solve this "attempt to index a local player (a nil value) Narrowlegobricks 12 — 6y
0
which line is it starmaq 1290 — 6y
0
which line is it? starmaq 1290 — 6y
0
Line 8 (local PlayerUI = Player:WaitForChild("PlayerGui").PlayerUI) Narrowlegobricks 12 — 6y
Ad

Answer this question