Replace the print(seat.Occupant) with print(“Connection ran”) and tell me if it runs when you leave the seat
Like this?
local previousPlayer
Seat:GetPropertyChangedSignal("Occupant"):Connect(function()
print("Connection ran")
if Seat.Occupant.Parent then
ProximityPrompt.Enabled = false
LockedPrompt.Enabled = false
local player = game.Players:GetPlayerFromCharacter(Seat.Occupant.Parent)
previousPlayer = player
game.ReplicatedStorage.HideCarPrompts:FireClient(player)
elseif previousPlayer then
ProximityPrompt.Enabled = true
LockedPrompt.Enabled = true
game.ReplicatedStorage.ShowCarPrompts:FireClient(previousPlayer)
previousPlayer = nil
end
end)
1 Like
Yes it runs when I leave the seat
If you print previousplayer, what does it give you when you exit the seat?
It prints SKETCHB0OK or whatever the players name is
Okay, try this instead then
local previousPlayer
Seat:GetPropertyChangedSignal("Occupant"):Connect(function()
if previousPlayer then
print("Player unseated")
ProximityPrompt.Enabled = true
LockedPrompt.Enabled = true
game.ReplicatedStorage.ShowCarPrompts:FireClient(previousPlayer)
previousPlayer = nil
elseif Seat.Occupant then
print("Player seated")
ProximityPrompt.Enabled = false
LockedPrompt.Enabled = false
local player = game.Players:GetPlayerFromCharacter(Seat.Occupant.Parent)
previousPlayer = player
game.ReplicatedStorage.HideCarPrompts:FireClient(player)
end
end)
1 Like
Thank you so much that works. I appreciate that so much you’ve spent over an hour helping me lol
Also as a small heads up, an if statement without any comparison checks is doing the same as
if variable ~= false and variable ~= nil then
Basically checking for whether or not the variable is true, or exists in the first place
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.