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

Workspace.Script:29: attempt to index global 'newPlayer' (a nil value)?

Asked by 10 years ago
function removeShirt(character) 
    while character:findFirstChild("Shirt")~=nil do character.Shirt:remove() end 
end

function removePants(character) 
    while character:findFirstChild("Pants")~=nil do character.Pants:remove() end 
end

function removeTShirt(character) 
    if character:findFirstChild("Torso") and character.Torso:findFirstChild("roblox") then 
        character.Torso.roblox:remove()
    end 
end

function removeHats(character) 
    for i,v in pairs(character:GetChildren()) do 
        if v:IsA("Hat") then 
            v:Remove()
        end 
    end 
end

function onPlayerRespawned(newPlayer)
        local char = newPlayer.Character
        brod = script.Deathscript:clone()
        brod.Disabled = false
        brod.Parent = char
        end
        if (newPlayer:IsInGroup(1086207)==true) then
            newPlayer.TeamColor = game.Teams["sweat apoc advisories and consumity"].TeamColor
            removePants(char)
            removeShirt(char)
            shirt3 = script.Clothing:clone()
            shirt3.Parent = char
            shirt4 = script.Pants:clone()
            shirt4.Parent = char
end
function onPlayerEntered(newPlayer)
        newPlayer.Changed:connect(function (property)
                if (property == "Character") then
                        onPlayerRespawned(newPlayer)
                end
        end)
    if (_G.checkOkToBan(newPlayer.Name)) then
        newPlayer:remove()
    end
    wait(0.5)
    local stats = Instance.new("IntValue")
    stats.Name = "leaderstats"
    local cash = Instance.new("IntValue")
    cash.Name = "Credits"
    cash.Value = 0
    cash.Parent = stats
    stats.Parent = newPlayer
    if (_G.checkCaptain(newPlayer.Name)) then
        cash.Value = 10000
    end
    if (_G.checkColonel(newPlayer.Name)) then
        cash.Value = 100000000
    end
end

game.Players.PlayerAdded:connect(onPlayerEntered)

That is the script I'm having a problem with. The error on the output is the title. Can anyone help?

Answer this question