Adding onto this, you should DEFINETLY use names over display names
People could literally just NOT have a display name and your whole code breaks
you wont have to check if players have a display name
if multiple people have the same display name, they’ll all be able to access the vehicle unless you have a hidden value for the name, or a different sanity check
Try using the script i sent above for handling occupant changes. The stringvalue being the player’s real username is fine, but you’ll have to check for the display name being " " not nil.
I also put a despawner in the script (it works when player resets), but idk how to break the countdown when a new owner is the occupant
script.Parent.OwnIt.Occupant:GetPropertyChangedSignal("Value"):Connect(function()
if script.Parent.OwnIt.Occupant.Value == "NoOccupant" then
for _, billboard in pairs(script.Parent.Parent:GetDescendants()) do
if billboard.Name == "DespawnGui" then
billboard.Enabled = true
for i = 80, 0, -1 do
billboard.TextLabel.Text = "Despawning in: " .. i
wait(1)
end
billboard.TextLabel:GetPropertyChangedSignal("Text"):Connect(function()
if billboard.TextLabel.Text == "Despawning in: 1" then
wait(1)
script.Parent.Parent:Destroy()
end
end)
end
end
elseif script.Parent.OwnIt.Occupant.Value == script.Parent.Occupant.Parent.Name then
for _, billboard in pairs(script.Parent.Parent:GetDescendants()) do
if billboard.Name == "DespawnGui" then
billboard.Enabled = true
billboard.TextLabel.Text = "Despawn timer starts when player resets"
end
end
end
end)
you don’t need to check if the text changed to that, after the for loop ends it will do whatever is after that, as for the checks, this is gonna be unoptimal again, but inside the despawning for loop you can check if there’s an occupant
for i = 80, 0, -1 do
if script.Parent.OwnIt.Occupant.Value == "NoOccupant" then return end
billboard.TextLabel.Text = "Despawning in: " .. i
wait(1)
end
script.Parent.Parent:Destroy()
I updated the checks, it was checking for if there was a script.Occupant.Value when it should check if the value wasnt equal to NoOccupant, the updated script should work for your system
Even with script.Parent.OwnIt, it also does not begin.
EDIT: Still doesn’t begin when the Occupant variable is removed.
ANOTHER EDIT: ok ima just solve this in a another topic