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