Im Trying to make a "Rage"GUI, That when press E, or Clicking on it, affects players from a distance, blinding them, and teleports the player who is clicking, to a random player... But im having this error with the PlayerGui, when it tries to blind the Victim...
"PlayerGui is Not A Valid Member of Player"
I Alredy changed it to :WaitForChild, but the message changes, saying:
"Infinite Yield Possible on players[i]:WaitForChild("PlayerGui")
The Error is on Line 063 Sorry if I'm not explaining it right, Here's The Script:
LocalPLR = game.Players.LocalPlayer
Humanoid = game.Players.LocalPlayer.Character:WaitForChild("Humanoid")
PTorso = game.Players.LocalPlayer.Character:WaitForChild("Torso")
local RSound = game.Workspace.RageSounds.FreddyKrueger
local Plrs = game.Teams.Survivor:GetPlayers()
Rage = 0
RageIsReady = false
GetRage = 100
Distance = 50
TPDistance = 300
function getrage()
Rage = Rage + GetRage
wait(0.01)
script.Parent.Text = "RAGE: "..Rage.." %"
if Rage >= 100 then
script.Parent.Text = "RAGE: Ready! Click to Use It!"
RageIsReady = true
end
end
function GetNearPly()
local Plrs = game.Players:GetPlayers()
local results = {}
for i=#Plrs,#Plrs do
if (Plrs[i].Character ~= nil) then
local t = Plrs[i].Character:FindFirstChild("Torso")
if (t ~= nil) then
if ((t.Position - PTorso.Position).magnitude <= Distance) and Plrs[i].Team ~= game.Teams.Freak then
results[#results + 1] = Plrs[i]
end
end
end
return results
end
end
function Teleport()
local randplayer = Plrs[math.random(1, #Plrs)]
print("Teleporting to: "..randplayer.Name.."")
LocalPLR.Character:MoveTo(randplayer.Character.Torso.Position)
end
function TheRage()
Teleport()
RSound:Play()
wait(0.3)
local players = GetNearPly()
for i=1,#players do
local Blind = game.Lighting.RageGUI.FreddyK.Blind
Blind:Clone().Parent = players[i]:WaitForChild("PlayerGui")--- im having the error HERE
end
end
script.Parent.MouseButton1Click:connect(function()
if RageIsReady == true then
TheRage()
Rage = 0
RageIsReady = false
script.Parent.Text = "RAGE: "..Rage.." %"
elseif RageIsReady == false then
print("Rage is Not Ready!")
end
end)
m = game.Players.LocalPlayer:GetMouse()
m.KeyDown:connect(function(key)
if key == "e" then
if RageIsReady == true then
TheRage()
Rage = 0
RageIsReady = false
script.Parent.Text = "RAGE: "..Rage.." %"
elseif RageIsReady == false then
print("Rage is Not Ready!")
end
end
end)
Humanoid.HealthChanged:connect(getrage)

5 comments
KeyDown is deprecated, do not use it in new work.
The infinite yield isn't an issue. It just alerts you that it could possibly wait for longs periods of time if the child doesn't load, which it should.
ikr, but it seems to never load
You have
LocalPlayerdefined already, so why're you retyping it over and over? >.>If your script is a server script(or normal script), then, you should change it to a LocalScript.