I have already researched around this topic but nothing seems to work, I made a script already and the code seems right with no error
I want it so that when the player is no longer sitting on the vehicle seat, the music goes to volume 0
Also I checked console and it didn’t print “Already 0”
local Drive = --path to the driver seat
local music = workspace.Music
Drive:GetPropertyChangedSignal("Occupant"):Connect(function()
if Drive.Occupant == nil then
music.Volume = 0
print("already 0!")
end
end)
local UIS = game:getservice("UserInputService")
part.Touched:Connect(funtion(hit)
if game.Plaers:GetPlayerFromCharacter then
UIS.InputBegan:Connect(funtion (input,GPE)
if input.UserInputType == Enum.UserInputType.Keyboard then
if input.KeyCode == Enum.KeyCode.Space then
-- code for the volume here
end
end
end)
end
end)```
Oh I kinda understand what you mean here, but it would cause bugs such as when resetting, the music will still be playing as the player didn’t press “space”
It’s a local script and for some reason won’t work
I have another script that sets the music to volume 1 when the button is being pressed, when I’m doing tests the local script didn’t really seem to alter the volume of that sound, even though the path to it is correct
The test is essentially pressing the button and leaving the car, and the volume didn’t change