Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

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

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

✓ Accepted answer

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.

3 comments

0

PlaceEvent is in ReplicatedStorage

0

Oops it wasnt i moved it and it was fixed. Thanks!

0

No problem!

This discussion is preserved as it was. New answers, comments, and votes are closed.