I have a part with click detector thats when clicked, it goes up to the player the playerscripts and finally setting the value of disable to false, when I did it on the first try it gave me an error so i put :WaitForChild()
for the player scripts, but its giving me this error Infinite yield possible on 'Players.ninjanerd601:WaitForChild("PlayerScripts")
the script:
local ReplicatedStorage = game:GetService("ReplicatedStorage") local remoteEvent = ReplicatedStorage:WaitForChild("PickupItem") local click = script.Parent.ClickDetector local text = script.Parent.MouseoverText.Value click.MouseClick:Connect(function(click) click:WaitForChild("PlayerScripts").Flashlight.Disabled = false --I have a :WaitForChild in this part script.Parent.Sound:Play() remoteEvent:FireAllClients(text) wait(0.235) script.Parent:Destroy() end)
please help, ty
I think this is because the click:WaitForChild("PlayerScripts")
at line 09
is referring to the click variable at line 04
, so when you are trying to :WaitForChild("PlayerScripts")
, it will wait for it the whole time and since the ClickDetector has no child with the name of PlayerScripts it will keep waiting.
-- Changed to player instead of click click.MouseClick:Connect(function(player) -- Also changed to player here player:WaitForChild("PlayerScripts").Flashlight.Disabled = false script.Parent.Sound:Play()