Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
500 views
in Technique[技术] by (71.8m points)

ROBLOX.Lua Infinite Yeild Possible Fix?

I am making this tool Wait For "PlaceEvent", but I keep getting this error:

21:58:52.024 - Infinite yield possible on 'ReplicatedStorage:WaitForChild("PlaceEvent")'
21:58:52.026 - Stack Begin
21:58:52.026 - Script 'Players.rohanskywalker.Backpack.Grass.Main', Line 7
21:58:52.026 - Stack End

Here is the script:

-- 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)
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

The output you are getting is not an error, but a warning. It is informing you that it is taking a long time for it to find "PlaceEvent" in ReplicatedStorage. There could be a couple causes for this.

Object isn't created yet

If you are creating the object in another script or moving the object into ReplicatedStorage, check that it doesn't have a separate error, causing it to abort before creating 'PlaceEvent'

Object is named Improperly

If it is being created properly, or it is in ReplicatedStorage from the beginning, check the name to make sure that it is EXACTLY 'PlaceEvent', otherwise your script will yield forever, never finding 'PlaceEvent'.

Those are the two possibilities for that warning, but remember it's only a warning and as soon as it finds that object the script will resume.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...