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

Error on line 60 help?

Asked by
Prioxis 673 Moderation Voter
10 years ago

Please make your question title relevant to your question content. It should be a one-sentence summary in question form.

I'm making an admin script and theres 2 errors first one saying on line 28 Character is a nil value and I believe the variable NewPlayer isn't working

**here's my script : **

--Commands

--chat commands--
--Green
--Red
--Yellow
--Blue

--key commands--
--z    

local AdminTable = {"YouShalllNotPass", "Player", "Player1"}
function IsAdmin(PlayerInstance)
 local PlayerName = PlayerInstance.Name:lower()
 for i = 1, #AdminTable do
  local AdminName = AdminTable[i]:lower()
  if AdminName == PlayerName then
   return true
  end
 end
 return false
end
game.Players.PlayerAdded:connect(function(NewPlayer)
 local NewPlayer = NewPlayer
 if IsAdmin(NewPlayer) then
print'Ventivian Commands have been hooked into the system'

local s1 = Instance.new("SelectionBox", NewPlayer.Character.Head)
    s1.Adornee = s1.Parent
    s1.Color = BrickColor.new("Medium stone grey")
    s1.Transparency = 0.5

local s2 = Instance.new("SelectionBox", NewPlayer.Character:FindFirstChild("Right Leg"))
        s2.Adornee = s2.Parent
            s2.Color = BrickColor.new("Medium stone grey")
                s2.Transparency = 0.5

local o = Instance.new("SelectionBox", NewPlayer.Character:FindFirstChild("Left Leg"))
        o.Adornee = o.Parent
            o.Color = BrickColor.new("Medium stone grey")
                o.Transparency = 0.5

local  s4 = Instance.new("SelectionBox", NewPlayer.Character:FindFirstChild("Right Arm"))
        s4.Adornee = s4.Parent
            s4.Color = BrickColor.new("Medium stone grey")
                s4.Transparency = 0.5

local  s5 = Instance.new("SelectionBox", NewPlayer.Character:FindFirstChild("Left Arm"))
        s5.Color = BrickColor.new("Medium stone grey")
            s5.Transparency = 0.5
        s5.Adornee = s5.Parent

        local h = Instance.new("StringValue", game.Workspace)
        h.Value = ""
        h.Name = "Kicked"

    local Mouse = NewPlayer:GetMouse()

    Mouse.KeyDown:connect(function(key)
        if key == "z" then

            if Player.PlayerGui:FindFirstChild("ScreenGui") then
                Player.PlayerGui.ScreenGui:Destroy()
            else
        local b = Instance.new("ScreenGui", NewPlayer.PlayerGui)

        local x = Instance.new("Frame", b)
        x.Name = "Menu"
        x.BackgroundColor3 = Color3.new(0, 255, 0)
        x.BackgroundTransparency = 0.5
        x.Size = UDim2.new(.15, 0, .5, 0)
        x.Position = UDim2.new(0, 10, 0, 10)

        local c = Instance.new("TextButton", x)
        c.Position = UDim2.new(.25, 0, .5, 0)
        c.BackgroundTransparency = 0
        c.BackgroundColor3 = Color3.new(0, 0, 0) 
        c.Size = UDim2.new(0, 100, 0, 25)
        c.TextColor3 = Color3.new(0, 255, 0)
        c.Style = 3
        c.Text = "Kick"

        local v = Instance.new("TextBox", x)
        v.Size = UDim2.new(0, 100, 0, 50)
        v.Position = UDim2.new(.25, 0, .25, 0)
        v.Name = "TextBox"

        local n = Instance.new("Frame", b)
        n.Name = "Menu2"
        n.BackgroundColor3 = Color3.new(0, 255, 0)
        n.BackgroundTransparency = 0.5
        n.Size = UDim2.new(.15, 0, .5, 0)
        n.Position = UDim2.new(.2, 0, 0, 10)

        local a = Instance.new("TextButton", n)
        a.Position = UDim2.new(.25, 0, .5, 0)
        a.BackgroundTransparency = 0
        a.BackgroundColor3 = Color3.new(0, 0, 0) 
        a.Size = UDim2.new(0, 100, 0, 50)
        a.TextColor3 = Color3.new(0, 255, 0)
        a.Style = 3
        a.Text = "GodMode"
        a.Font = "SourceSansBold"
        a.FontSize = "Size24"

        local a1 = Instance.new("TextBox", n)
        a1.Position = UDim2.new(.25, 0, .30, 0)
        a1.Size = UDim2.new(0, 100, 0, 50)

        local a2 = Instance.new("TextButton", n)
        a2.Position = UDim2.new(.25, 0, .1, 0)
        a2.BackgroundTransparency = 0
        a2.BackgroundColor3 = Color3.new(0, 0, 0) 
        a2.Size = UDim2.new(0, 100, 0, 50)
        a2.TextColor3 = Color3.new(0, 255, 0)
        a2.Style = 3
        a2.Text = "Change Fog"
        a2.Font = "SourceSansBold"
        a2.FontSize = "Size12"

        local n1 = Instance.new("Frame", b)
        n1.Name = "Menu3"
        n1.BackgroundColor3 = Color3.new(0, 255, 0)
        n1.BackgroundTransparency = 0.5
        n1.Size = UDim2.new(.15, 0, .5, 0)
        n1.Position = UDim2.new(.4, 0, 0, 10)

        local n2 = Instance.new("TextBox", n1)
        n2.Position = UDim2.new(.25, 0, .30, 0)
        n2.Size = UDim2.new(0, 100, 0, 50)  

        local c1 = Instance.new("TextButton", n1)
        c1.Position = UDim2.new(.25, 0, .5, 0)
        c1.BackgroundTransparency = 0
        c1.BackgroundColor3 = Color3.new(0, 0, 0) 
        c1.Size = UDim2.new(0, 100, 0, 25)
        c1.TextColor3 = Color3.new(0, 255, 0)
        c1.Style = 3
        c1.Text = "Change WalkSpeed"

        --button scripts

        a.MouseButton1Down:connect(function(click2)
            if NewPlayer.Character.Humanoid.MaxHealth == math.huge then
                NewPlayer.Character.Humanoid.MaxHealth = 100 
            else
                NewPlayer.Character.Humanoid.MaxHealth = math.huge
                end
            end)

        c.MouseButton1Down:connect(function(click)
            game.Workspace.Kicked.Value = NewPlayer.PlayerGui.ScreenGui.Menu.TextBox.Text

    local o1 = Instance.new("SelectionBox", game.Workspace:FindFirstChild(game.Workspace.Kicked.Value):FindFirstChild("Left Leg"))
        o1.Adornee = o1.Parent
        o1.Color = BrickColor.new("Medium stone grey")
        o1.Transparency = 0.5

        local o2 = Instance.new("SelectionBox", game.Workspace:FindFirstChild(game.Workspace.Kicked.Value):FindFirstChild("Left Arm"))
        o2.Adornee = o2.Parent
        o2.Color = BrickColor.new("Medium stone grey")
        o2.Transparency = 0.5

        local o3 = Instance.new("SelectionBox", game.Workspace:FindFirstChild(game.Workspace.Kicked.Value):FindFirstChild("Right Arm"))
        o3.Adornee = o3.Parent
        o3.Color = BrickColor.new("Medium stone grey")
        o3.Transparency = 0.5

            local o4 = Instance.new("SelectionBox", game.Workspace:FindFirstChild(game.Workspace.Kicked.Value):FindFirstChild("Right Leg"))
        o4.Adornee = o4.Parent
        o4.Color = BrickColor.new("Medium stone grey")
        o4.Transparency = 0.5

        local o5 = Instance.new("SelectionBox", game.Workspace:FindFirstChild(game.Workspace.Kicked.Value):FindFirstChild("Torso"))
        o5.Adornee = o5.Parent
        o5.Color = BrickColor.new("Medium stone grey")
        o5.Transparency = 0.5
        wait(1)
        game.Players:FindFirstChild(game.Workspace.Kicked.Value):Kick()
        end)

            a2.MouseButton1Down:connect(function(click3)
            game.Lighting.FogEnd = a1.Text
            end)

            c1.MouseButton1Down:connect(function(click4)
            Player.Character.Humanoid.WalkSpeed = n2.Text
            end)


NewPlayer.Chatted:connect(function(message)
if message == "Blue" then
s1.Color = BrickColor.new("Bright blue")
s2.Color = BrickColor.new("Bright blue")
o.Color = BrickColor.new("Bright blue")
s4.Color = BrickColor.new("Bright blue")
s5.Color = BrickColor.new("Bright blue")    
end
end)

NewPlayer.Chatted:connect(function(message)
if message == "Red" then
s1.Color = BrickColor.new("Bright red")
s2.Color = BrickColor.new("Bright red")
o.Color = BrickColor.new("Bright red")
s4.Color = BrickColor.new("Bright red")
s5.Color = BrickColor.new("Bright red")
end
end)

NewPlayer.Chatted:connect(function(message)
if message == "Green" then
s1.Color = BrickColor.new("Bright green")
s2.Color = BrickColor.new("Bright green")
o.Color = BrickColor.new("Bright green")
s4.Color = BrickColor.new("Bright green")
s5.Color = BrickColor.new("Bright green")
end
end)

NewPlayer.Chatted:connect(function(message)
if message == "Yellow" then
s1.Color = BrickColor.new("Bright yellow")
s2.Color = BrickColor.new("Bright yellow")
o.Color = BrickColor.new("Bright yellow")
s4.Color = BrickColor.new("Bright yellow")
s5.Color = BrickColor.new("Bright yellow")
    end
end)

        end
    end
end)
 end
end)





1 answer

Log in to vote
1
Answered by 10 years ago

First, get rid of line 24. You don't need it.

Second, add this line under line 23:

repeat wait() until NewPlayer.Character --Waits until the player's character is available.
0
thank you but now I have an error on line 60 Prioxis 673 — 10y
0
What's the error? Spongocardo 1991 — 10y
0
line 59 it says that Mouse is a nil value Prioxis 673 — 10y
1
You can't use GetMouse in a server script, so you have to use a LocalScript. Spongocardo 1991 — 10y
View all comments (2 more)
0
then it doesn't work Prioxis 673 — 10y
0
Then you need to use RemoteFunctions. Tkdriverx 514 — 10y
Ad

Answer this question