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)
I hope it works
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 = game.Players.LocalPlayer.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)