Hello!
I am trying to incorporate a line into my script that would remove ownership from the property upon player exit and revert back to "No Owner" So a new player can take over:
--//Variables
local owner = script.Parent.OwnerName
local isOpen = false
local waitTime = 2
local door = script.Parent
--//Ensures that the door is closed
door.CanCollide = true
door.Transparency = 0
door.Anchored = true
script.Parent.Touched:connect(function(hit)
local humanoid = hit.Parent:FindFirstChild("Humanoid")
if humanoid then
local plr = game.Players:GetPlayerFromCharacter(hit.Parent)
if plr then
--//A player
if owner.Value == "" then
--//No Current Owner, set player as new owner
owner.Value = plr.Name
elseif plr.Name == owner.Value then
--//The owner
if isOpen == false then
isOpen = true
door.CanCollide = false
door.Transparency = 0.8
wait(waitTime)
door.CanCollide = true
door.Transparency = 0
isOpen = false
end
end
end
end
end)
and my parent script:
--//Variables
local model = script.Parent
local owner = script.Parent.Head.OwnerName
--//Initializes Name
function check()
if owner.Value == "" then
model.Name = "No current owner"
else
model.Name = owner.Value .. "'s Dorm Room"
end
end
owner.Changed:connect(function()
check()
end)
check()
Any help would be appreciated!
Thanks

4 comments
game.Players.PlayerRemoved will help you
I might be wrong but when a player leaves the network owner of the instance is set to
nilwhich means the server controls it.:connect is deprecated use :Connect
Can someone please explain where I would input game.Players.PlayerRemoved for this to work?