Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

"PlayerGui is Not A Valid Member of Player"?

Asked by 5 years ago

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)
0
KeyDown is deprecated, do not use it in new work. User#19524 175 — 5y
0
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. Lugical 425 — 5y
0
ikr, but it seems to never load zMadZeus 6 — 5y
0
You have `LocalPlayer` defined already, so why're you retyping it over and over? >.> TheeDeathCaster 2368 — 5y
0
If your script is a server script(or normal script), then, you should change it to a LocalScript. saSlol2436 716 — 5y

1 answer

Log in to vote
0
Answered by 5 years ago

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)
0
xD i did such a small change and im not a professional scripter and i made it work xD np <3 Lolamtic 63 — 5y
Ad

Answer this question