Hi there! I’m currently just making something for fun, and I’m trying to call to a folder inside the player [when you’re in studio: Players > srauf1 > PlayerValues].
PromptPart.Touched:Connect(function(Hit)
local Humanoid = Hit.Parent:FindFirstChild("Humanoid")
if Humanoid then
local PlayerValues = Humanoid.Parent:WaitForChild("PlayerValues")
I assume this is what prevents the rest of the script [which seems unnecessary to present at the minute, as it probably has nothing to do with the warning considering I got it beforehand.
The warning I receive: Infinite yield possible on 'Workspace.srauf1:WaitForChild("PlayerValues")' - Studio
I’m not sure if there’s an issue with how I’m calling for ‘PlayerValues’, but I’d just love to learn how to fix it.
Thanks!
Edit: It says ‘Workspace.srauf1’, where the folder isn’t located in the Workspace. How can I access the actual ‘Player’, if you know what I mean.
Double edit: I realise it only says Workspace because Humanoid.Parent would be the Player Character model in the Workspace. However, when I change it to Player from a PlayerAdded function, I receive the same warning.
'Infinite yield possible on ‘Players.srauf1:WaitForChild(“PlayerValues”)’
If you’re trying to get something inside of the player’s player instance, then you can use the GetPlayerFromCharacter function of the Players service, giving it the parent of the thing that touched the part
PromptPart.Touched:Connect(function(Hit)
local player = game:GetService("Players"):GetPlayerFromCharacter(Hit.Parent)
if player then
local PlayerValues = player:WaitForChild("PlayerValues")
Which returns the player isntance if it found one using the Character given or nil if it hasn’t
Also be certain you gave the right name as it may still give the same error otherwise
PromptPart.Touched:Connect(function(Hit)
local Player = game:GetService("Players"):GetPlayerFromCharacter(Hit.Parent)
if Player then
local PlayerValues = Player:WaitForChild("PlayerValues")
It returns the same error:
`Infinite yield possible on ‘Players.srauf1:WaitForChild(“PlayerValues”)’ - Studio’
The folder is definitely called 'PlayerValues!
(I don’t know if it’s relevant to the problem, but it takes like 5 seconds for it to return the warning after the PromptPart is touched)
Okay, now anotehr question, is this PlayerValues folder created instantly, or is created at some point in the game? IF it’s made instantly then the name is incorrect or it’s taking a very long tiem to load
Okay now I’m really confused, nothing should be causing that warning as it exists. And I think directly indexing would cause an error. Try double checking the names to ensure their exact? Copy and paste the PlayerValues in your script and paste it where it makes the folder?
Something else has to be going on, look through everything related to it and if there’s some small mistake?
The only thing I can think of is if it needs a debounce or anything?
It takes 5 seconds for the warning to appear in Output after touching. I’ll check the scripts now.
Yep that’s why then, only the client can see the folder, the server doesn’t notice it existing. I think you need to make the folder from a regular script.