local Players = game:GetService("Players")
local player = Players.LocalPlayer
local finder = workspace:WaitForChild(player.Name.."'s Car")
task.wait(.6)
local CarName = finder.CarName.Value
local PathToSeat = finder.DriveSeat
local function handleOccupantChange()
print("TEST")--Only print when car gets spawned in
end
PathToSeat:GetPropertyChangedSignal("Occupant"):Connect(function(property)
print("TEST 1")
if property == "Occupant" then
handleOccupantChange()
else
end
end)
handleOccupantChange()
I am try to achieve is when a player sits in the DriveSeat it print TEST. TEST 1 prints fine. Why won’t it print TEST when player is sitting in drive seat? But it will print TEST when I first spawn in the car.
the if check in the getpropertychangedsignal is useless because it will only fire when the occupant property gets changed, also getpropertychangedsignal returns a rbxscriptsignal not which property changed
because you are getting the signal for a property being changed and then asking if that property got changed using a variable that doesnt exist from that event
local Players = game:GetService("Players")
local player = Players.LocalPlayer
local finder = workspace:WaitForChild(player.Name.."'s Car")
task.wait(.6)
local CarName = finder.CarName.Value
local PathToSeat = finder.DriveSeat
local function handleOccupantChange()
print("TEST")--Only print when car gets spawned in
end
PathToSeat:GetPropertyChangedSignal("Occupant"):Connect(function()
print("TEST 1")
local occupant = PathToSeat.Occupant
if occupant then
handleOccupantChange()
else
end
end)
handleOccupantChange()