so bassicly whenever is it i want it to make a sound and when i leave the seat its makes a sound but it doesnt work
local a = script.Parent.Unsits local b = script.Parent.Sits local c = script.Parent if c.Occupant ~= nil then b:Play() end if c.Occupant == nil then a:Play() end
Well, you're on the right track. However your mistake is that you're running this code as soon as the server starts, and it only runs once. To run only when a player sits in a seat we're going to want to run the :GetPropertyChangedSignal()
method on the seat and listen for the Occupant property.
local Seat = script.Parent Seat:GetPropertyChangedSignal("Occupant"):Connect(function() end)
This code will run whenever somebody sits or leaves the specific seat.
Now of course we will want to check which of those it is, and play the sound depending on whether they sat down or left the seat.
local Seat = script.Parent local SoundOne = script.Parent:WaitForChild("Sits") local SoundTwo = script.Parent:WaitForChild("Unsits") Seat:GetPropertyChangedSignal("Occupant"):Connect(function() if Seat.Occupant ~= nil then SoundOne:Play() else SoundTwo:Play() end end)
I hope this helped. You should take a look at this link to better understand the use of this method for future reference.
If I did help, then please mark my answer as accepted or reply to this answer if you need further help!