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)
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