Removal of lighting effects doesn't work on death - Local Script

Hello, I’ve made a silly little drink that basically gives you a large speed boost at the expense of your HP draining, I’ve also made a cure for it, which works fine…

What doesn’t work though, is the script that makes it stop when you die.

I don’t have any errors, only this warning:

Infinite yield possible on 'Players.RetroPect:WaitForChild("Character")

After dying - no error pops up, this warning pops up every time I test.

local plr = game:GetService("Players").LocalPlayer
local chr = plr.Character or plr.CharacterAdded:Wait()
local hum = chr:WaitForChild("Humanoid")

Line 2 is your error. Character in that case is a property/reference of the Player not a file.
That works sometimes because your Character is actually loaded but at times that may take a moment. Then that line will Infinite yield. So you do it both ways with that added CharacterAdded:Wait() line. If the reference is not loaded yet it will OR to wait for the Character.

But: local char = player:WaitForChild(“Character”) is always a miss call, due to this.

Sorry for the late reply.

Thank you, this worked!

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.