Part of script no longer works because of an update

Hello. I have this vehicle owning script.
However, the despawn countdown part broke in a roblox update:

script.Parent.OwnIt.Occupant:GetPropertyChangedSignal("Value"):Connect(function()
	if script.Occupant.Value == "NoOccupant" then
		for _, billboard in pairs(script.Parent.Parent:GetDescendants()) do
			if billboard.Name == "DespawnGui" and billboard ~= nil then
				billboard.Enabled = true
				for i = 80, 0, -1 do
					if script.Occupant.Value ~= "NoOccupant" then return end

					billboard.TextLabel.Text = "Despawning in: " .. i
					print(script.Parent.Parent.Name .. " is being despawned...")
					wait(1)
				end
				script.Parent.Parent:Destroy()
				print("Sucessfully despawned " .. script.Parent.Parent.Name)
			else
				wait(80)
				script.Parent.Parent:Destroy()
				print("Sucessfully despawned " .. script.Parent.Parent.Name)
			end
		end
	elseif script.Occupant.Value ~= "NoOccupant`" then
		for _, billboard in pairs(script.Parent.Parent:GetDescendants()) do
			if billboard.Name == "DespawnGui" then
				billboard.Enabled = false
				billboard.TextLabel.Text = "Despawn timer starts when player resets"
			end
		end
	end
end)

The timer won’t display anymore.

6 Likes

Can you include any errors you’re getting?

2 Likes

I am not getting any errors in the output.

2 Likes

You have a typo (on your second if statement):

Change that to this or just make it an else statement:

"NoOccupant"

If you could show me any other scripts that relate to this one, that would help.

1 Like

Fixing the typo does not fix it.

1 Like

1 Like

There isnt any other scripts in my game that is related to this.

1 Like

Could you show your explorer of the script?

1 Like


image

1 Like

Whats being printed, you have alot of print statements, there, is there anything being printed (not just errors)?

There isn’t anything printed in the output.

Also your script is saying script.Parent.OwnIt.Occupant,

script.Parent Is OwnIt, so that won’t work. suprised theres no errors.

Secondly, why would the string values “Occupant” property change, is there a script changing it? Did you mean to use the VehicleSeats “Occupied” property and not the string value?

Use the .Occupant value of the seat to check for people sitting. You can also remove the Occupant StringValue you have.

Code:

local Seat = script.Parent

Seat:GetPropertyChangedSignal("Occupant"):Connect(function()
	if Seat.Occupant then
		for _, billboard in pairs(script.Parent.Parent:GetDescendants()) do
			if billboard.Name == "DespawnGui" and billboard ~= nil then
				billboard.Enabled = true
				for i = 80, 0, -1 do
					if script.Occupant.Value ~= "NoOccupant" then return end

					billboard.TextLabel.Text = "Despawning in: " .. i
					print(script.Parent.Parent.Name .. " is being despawned...")
					task.wait(1)
				end
				script.Parent.Parent:Destroy()
				print("Sucessfully despawned " .. script.Parent.Parent.Name)
			else
				task.wait(80)
				
				script.Parent.Parent:Destroy()
				print("Sucessfully despawned " .. script.Parent.Parent.Name)
			end
		end
	else
		for _, billboard in pairs(script.Parent.Parent:GetDescendants()) do
			if billboard.Name == "DespawnGui" then
				billboard.Enabled = false
				billboard.TextLabel.Text = "Despawn timer starts when player resets"
			end
		end
	end
end)

Seat is not script.Parent.OwnIt

Seat is Script.Parent*

Fixed.

The vehicle owner script is completely based on values, not occupant.

What sets those values then? You said

Here is the rest of the script, which sets those values.

script.Parent:GetPropertyChangedSignal("Occupant"):Connect(function()
	if script.Parent.Occupant then
		local occupant = script.Parent.Occupant
		if script.Occupant.Value == "NoOccupant" or script.Occupant.Value == occupant.Parent.Name then

			script.Occupant.Value = occupant.Parent.Name
			
			for _, billboard in pairs(script.Parent.Parent:GetDescendants()) do
				if billboard.Name == "OccupantGui" and billboard ~= nil then
					if occupant.DisplayName == nil then
						billboard.TextLabel.Text = occupant.Parent.Name .. "'s Vehicle"
					else
						billboard.TextLabel.Text = occupant.DisplayName .. "'s Vehicle"
					end
				end
			end

			local deathConnection

			deathConnection = occupant.Died:Connect(function()
				script.Occupant.Value = "NoOccupant"
				deathConnection:Disconnect()
			end )
		else
			print("Occupant is not owner")
			wait(.1)
			local sw = script.Parent:FindFirstChild("SeatWeld")
			sw:Destroy()
		end
	else
		script.Occupant:GetPropertyChangedSignal("Value"):Connect(function()
			for _, billboard in pairs(script.Parent.Parent:GetDescendants()) do
				if billboard.Name == "OccupantGui" and script.Occupant.Value == "NoOccupant" and billboard ~= nil then
					billboard.TextLabel.Text = "Vacant Vehicle"
				end
			end
		end)
	end
end)