Code doesn't work properly if a boolean is true

I’m trying to make a seat that plays songs from a playlist, however if the boolean songsEnabled is true then code behaves in an unexpected manner.

here’s the code:

If songsEnabled is false then the speed Gui that’s connected to the events DriverSeated and DriverUnSeated works fine, but if it’s true then it sometimes goes up to 2 studs per second and after that no matter what I do it doesn’t go above 0.
The other bug is that when I get off the seat it simply stops the song and plays another one.

Here are the functions I’m calling outside of the block above:

The module Playlists simply has a table inside the module table filled with songId's

The first bug is fairly perplexing. Could you share the local script that you have connected to the script?

The second bug is because you’ve connected the script controlling songs to the vehicleSeat:GetPropertyChangedSignal(“Occupant”) meaning it will fire every time that property changes.

Could you also take a screenshot or video of the issue so that I can properly visualise what’s happening?

2 Likes

Sure, meanwhile I actually managed to fix the songs continuing to play and realized that small of a mistake, but the velocity is still a problem. Here’s the script:

About a video I don’t have OBS set up right now, but here’s the scene:


-songsEnabled = false


-songsEnabled = true

Oh wait it contains that other fishing boat… that’s so dum from me :smiley:
(boatDriven is not set properly, feels like I’ve been blindfolded)

Are you able to move with songsEnabled = true, or is it just the GUI that doesn’t work? Could you put a print in the local script, in the part which controls the speedometer, and also one in the songEnabled part of the server script?

I fixed the bug a few minutes ago and the problem was that it detected the wrong boat. Also I realized that event listeners on the client only need the player so they can know where to execute, but it isn’t in the arguments, so I sent the seat object to the client and tracked it’s speed.

1 Like