When creating a SeatWeld manually to a non-Seat, ClickToMove controls throw an error

By manually creating SeatWelds to non-Seat parts (which still allows jumping to break the weld), the ClickToMove player script (who knew that existed?) throws an error. This is because the Seated event will return that the player is seated (active = true), but the seat part is not (always?) known (currentSeatPart = nil in my case).

Error:

23:38:04.164 - Players.Player1.PlayerScripts.CameraScript.ClickToMove:1486: attempt to index local 'currentSeatPart' (a nil value)
23:38:04.164 - Stack Begin
23:38:04.165 - Script 'Players.Player1.PlayerScripts.CameraScript.ClickToMove', Line 1486 - upvalue onSeated
23:38:04.165 - Script 'Players.Player1.PlayerScripts.CameraScript.ClickToMove', Line 1533
23:38:04.165 - Stack End

Arguably the real bug is that the Seated event does not properly return the currentSeatPart instance the SeatWeld is attached to. Either way, that error is caused by something going wrong here.

Going to make a change to check that the seat part is non nil in the ClickToMove script.

See here on GitHub: Check that currentSeatPart is non-nil in onSeated function by DarraghGriffin · Pull Request #769 · Roblox/Core-Scripts · GitHub

Can you post reproduction code/steps so someone can look into why the part passed to the OnSeated event is nil?

3 Likes

Appearantly just setting Humanoid.Sit to true also causes it.

wait(2);

local char = game.Players.LocalPlayer.Character;
char.Humanoid.Sit = true;

Scrap the latter part about the SeatWeld, I think I am doing something else wrong here myself.