Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Why does output say PlayerGui is not a member of Player?

I made this code that basically bans someone from the game when you use a command. The command works fine, the output says that "PlayerGui is not a valid member of Player". Is it because this is in a local script?

plr=game.Players.LocalPlayer
plr.Chatted:connect(function(msg)
	if string.lower(msg:sub(1,10))==(":blacklist") then
		print("BLACKLISTING!")
		aname=msg:sub(12)
		if game.Players:FindFirstChild(aname) then
			p=game.Players:FindFirstChild(aname)
	while true do 
			wait()
			if p.Character.Humanoid then
				debounce=true
				a=Instance.new("ScreenGui") 
				a.Parent=p.PlayerGui --This is where output is giving a message
				b=Instance.new("TextLabel")
				b.Parent=a
				b.Position=UDim2.new(0,.5,0,.5)
				b.Size=UDim2.new(1,1,1,1)
				b.Text="You have been blacklisted from this place. PM MathisGuidonsio for an appeal"
				b.BackgroundTransparency=.6
				b.BackgroundColor3=Color3.new(0,0,0)
				b.TextStrokeTransparency=0
				b.TextScaled=true
				b.TextColor3=Color3.new(255, 255, 255)
				StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.All, false)
				StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.Health, true)
				p.Character.Humanoid.WalkSpeed=0
				for i=1,50 do
					wait(.01)
					p.Character.Humanoid.Health=p.Character.Humanoid.Health-2
				end
				a:Destroy()
			end
		
	end
	end
	end
	end)

2 comments

0

Perhaps the player left the game. Make your while loop check whether or not 'p' is nil.

0

The player did not leave the game. I tried it in studio with a server, as well as with an alt on my phone. Both had the same message.

1 answer

I had a problem like this once. Try this

plr=game.Players.LocalPlayer
local PlayerGui = plr.WaitForChild("PlayerGui") 
plr.Chatted:connect(function(msg)
    if string.lower(msg:sub(1,10))==(":blacklist") then
        print("BLACKLISTING!")
        aname=msg:sub(12)
        if game.Players:FindFirstChild(aname) then
            p=game.Players:FindFirstChild(aname)
    while true do 
            wait()
            if p.Character.Humanoid then
                debounce=true
                a=Instance.new("ScreenGui") 
                a.Parent= PlayerGui --This is where output is giving a message
                b=Instance.new("TextLabel")
                b.Parent=a
                b.Position=UDim2.new(0,.5,0,.5)
                b.Size=UDim2.new(1,1,1,1)
                b.Text="You have been blacklisted from this place. PM MathisGuidonsio for an appeal"
                b.BackgroundTransparency=.6
                b.BackgroundColor3=Color3.new(0,0,0)
                b.TextStrokeTransparency=0
                b.TextScaled=true
                b.TextColor3=Color3.new(255, 255, 255)
                StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.All, false)
                StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.Health, true)
                p.Character.Humanoid.WalkSpeed=0
                for i=1,50 do
                    wait(.01)
                    p.Character.Humanoid.Health=p.Character.Humanoid.Health-2
                end
                a:Destroy()
            end

    end
    end
    end
    end)

If this doesn't work then I'm not sure. I'm not a very good coder, but I want to at least try to help :p

1 comment

2

its :WaitForChild(), not .WaitForChild() ( : not . )

This discussion is preserved as it was. New answers, comments, and votes are closed.