Despawn timer won't begin when player resets

Hello. Attempting to put a despawner in a vehicle owning script, every time I reset with my vehicle, the despawn countdown does not begin.

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
    				if script.Parent.OwnIt.Occupant.Value == "NoOccupant" then return end

    				billboard.TextLabel.Text = "Despawning in: " .. i
    				wait(1)
				end
				script.Parent.Parent:Destroy()
			end
		end
	elseif script.Parent.OwnIt.Occupant.Value ~= "NoOccupant" 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)
1 Like

Have you tried using print statements to see if the event fires? Have you also checked to see if the condition is satisfy in order for the code to run?

1 Like

I used print statements.
The prints were not sending in the output.

1 Like

For both the condition and event? If that’s the case, the problem relies on your event. You must find a way to fire the event by testing some other ways, and later implement back the code so you can continue testing the other conditions inside your code.

1 Like

Ok nevermind, managed to fix it by replacing the == to ~= in this part:

if script.Parent.OwnIt.Occupant.Value == "NoOccupant" then return end
1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.