I'm trying to see if I can make a script that checks what seat the player is on, and if they are on a certain seat it will do something, like change the camera subject or explode something.
This is the code I got:
wait() local plr = game.Players.LocalPlayer local chr = plr.Character or plr.CharacterAdded:wait() local hum = chr:WaitForChild("Humanoid") hum.Changed:connect(function() if hum.SeatPart == "Seat" then print("a") elseif hum.SeatPart == "CamSeat" then workspace.CurrentCamera.CameraSubject = chr.Head end end)
SeatPart
property holds an object reference, not a string. So simply add a .Name
. Remember to use a LocalScript
.local plr = game.Players.LocalPlayer local chr = plr.Character or plr.CharacterAdded:Wait() -- :wait is deprecated local hum = chr:WaitForChild("Humanoid") hum.Changed:Connect(function(prop) -- connect is deprecated if prop ~= "SeatPart" then return end -- if the property wasn't the seatpart then end the function if hum.SeatPart.Name == "Seat" then print("a") elseif hum.SeatPart.Name == "CamSeat" then workspace.CurrentCamera.CameraSubject = chr.Head end end)