Hello. I have a script that lets the player owns the vehicle once they hop in.
It works, except for this part:
script.Parent.OwnVehicle.Occupant:GetPropertyChangedSignal("Value"):Connect(function()
if script.Occupant.Value == "NoOccupant" then
for _, billboard in pairs(script.Parent:GetDescendants()) do
if billboard.Name == "OccupantGui" then
billboard.TextLabel.Text = "Vacant Vehicle"
print("no occupant")
end
end
end
end)
The occupant UI is clearly there, idk why it won’t change.
The despawn timer (which is in the same chunk) works however.
I don’t quite get it: what are you trying to accomplish? How are you getting the vehicle’s code to trigger? Can you send me your full code and what you’re trying to do with it?
This chunk of code vacates the vehicle when it’s owner dies/leaves, or if owner claims a vehicle over the limit.
Here is another part of the code, which detects if there is an occupant in the seat.
I noticed an issue: in plrLeaving, you disconnect from deathConnection rather than plrLeaving. Not the root of your issues, but a problem nonetheless.
Are there any errors? What exactly is calling OwnVehicle()? What is vs.Occupant? Why are you setting the script’s parent’s parent to workspace when they leave or die?
Also, when you set the billboard text, if the player doesn’t have a displayname, you use occupant.Parent.Name, but if they do you use occupant.DisplayName? Where did the extra parent come from in the first if?