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

What is wrong with these lines of code [2 lines]?

Asked by 9 years ago

W001: Unknown global 'player' was the error I got for the first 2 lines of code on this script.

game.Players.PlayerRemoving:connect(player) -- error here
    if player.Parent.Name==script.Parent.Owner.Value then -- error here
    script.Parent.Owner.Value = "Nobody"
    ------------------------------------
    local gate = script.Parent.Gate
    if gate.Transparency ~= 0 then
        gate.Transparency = 0
        gate.CanCollide = true
    end
    ------------------------------------
    local co = script.Parent.OwnershipDoor.ClaimOwnership
    co.BrickColor = BrickColor.new("Medium stone grey")
    co.Parent.OwnerName.SurfaceGui.Owner.Text = "Claim Ownership"
    co.Defender.Disabled = true
    co.Claim.Disabled = false

    script.Parent.Owner.Value = "Nobody"
    ------------------------------------
    local gate = script.Parent.Gate
    if gate.Transparency ~= 0 then
        gate.Transparency = 0
        gate.CanCollide = true
    end
    ------------------------------------
    local co = script.Parent.OwnershipDoor.ClaimOwnership
    co.BrickColor = BrickColor.new("Medium stone grey")
    co.Parent.OwnerName.SurfaceGui.Owner.Text = "Claim Ownership"
    co.Defender.Disabled = true
    co.Claim.Disabled = false
end

2 answers

Log in to vote
0
Answered by 9 years ago

Your forgot to make it a function.

game.Players.PlayerRemoving:connect(function(player) -- Edit here
    if player.Parent.Name==script.Parent.Owner.Value then
    script.Parent.Owner.Value = "Nobody"
    ------------------------------------
    local gate = script.Parent.Gate
    if gate.Transparency ~= 0 then
        gate.Transparency = 0
        gate.CanCollide = true
    end
    ------------------------------------
    local co = script.Parent.OwnershipDoor.ClaimOwnership
    co.BrickColor = BrickColor.new("Medium stone grey")
    co.Parent.OwnerName.SurfaceGui.Owner.Text = "Claim Ownership"
    co.Defender.Disabled = true
    co.Claim.Disabled = false

    script.Parent.Owner.Value = "Nobody"
    ------------------------------------
    local gate = script.Parent.Gate
    if gate.Transparency ~= 0 then
        gate.Transparency = 0
        gate.CanCollide = true
    end
    ------------------------------------
    local co = script.Parent.OwnershipDoor.ClaimOwnership
    co.BrickColor = BrickColor.new("Medium stone grey")
    co.Parent.OwnerName.SurfaceGui.Owner.Text = "Claim Ownership"
    co.Defender.Disabled = true
    co.Claim.Disabled = false
end) --Edit here (added a ")" )
Ad
Log in to vote
-1
Answered by 9 years ago
game.Players.PlayerRemoving:connect(function(player) -- you need to add function <<
    if player.Name==script.Parent.Owner.Value -- I believe you dont need Parent because Player=game.players.RemovedPlayer
    then 
    script.Parent.Owner.Value = "Nobody" 
    ------------------------------------
    local gate = script.Parent.Gate
    if gate.Transparency ~= 0 then
        gate.Transparency = 0
        gate.CanCollide = true
    end
    ------------------------------------
    local co = script.Parent.OwnershipDoor.ClaimOwnership
    co.BrickColor = BrickColor.new("Medium stone grey")
    co.Parent.OwnerName.SurfaceGui.Owner.Text = "Claim Ownership"
    co.Defender.Disabled = true
    co.Claim.Disabled = false

    script.Parent.Owner.Value = "Nobody"
    ------------------------------------
    local gate = script.Parent.Gate
    if gate.Transparency ~= 0 then
        gate.Transparency = 0
        gate.CanCollide = true
    end
    ------------------------------------
    local co = script.Parent.OwnershipDoor.ClaimOwnership
    co.BrickColor = BrickColor.new("Medium stone grey")
    co.Parent.OwnerName.SurfaceGui.Owner.Text = "Claim Ownership"
    co.Defender.Disabled = true
    co.Claim.Disabled = false
end end)

Answer this question