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

How to fix Infinite Yeild possible in a LocalScript inside a tool?

Asked by 7 years ago

I need some help on this, the script always says:

10:34:04.532 - Infinite yield possible on 'ReplicatedStorage:WaitForChild("PlaceEvent")'
10:34:04.534 - Stack Begin
10:34:04.535 - Script 'Players.TinyScripter.Backpack.Grass.Main', Line 7
10:34:04.536 - Stack End

Does anybody know how to fix it? Here is the script I am using:

-- Local Script
local tool = script.Parent
local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
local clickEvent = tool.ClickEvent
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local PlaceEvent = ReplicatedStorage:WaitForChild("PlaceEvent")

local function onActivate()
 local clickLocation = mouse.hit
    clickEvent:FireServer(clickLocation)
    PlaceEvent:FireServer()
end

tool.Activated:connect(onActivate)

1 answer

Log in to vote
0
Answered by 7 years ago

Make sure you have the PlaceEvent in ReplicatedStorage and that the name is correct. By using WaitForChild(), you are putting the code on hold until it is able to find the object in that directory. That gives you the Infinite yield possible error, which means the code will yield (wait) forever until the object is found.

0
PlaceEvent is in ReplicatedStorage TinyScripter 70 — 7y
0
Oops it wasnt i moved it and it was fixed. Thanks! TinyScripter 70 — 7y
0
No problem! User#17862 0 — 7y
Ad

Answer this question