Hey there!
I am implementing steering capabilities to a wheelchair I created where the player moves the mouse to make it turn.
However, I came across an issue where the wheels that are attached to the base of the wheelchair with hinge constraints seem to detach every time the wheelchair starts rotating, evidently lagging behind:
Here is the code to the server script used to rotate the chair (part is the primary part of the wheelchair):
RotateChair.OnServerEvent:Connect(function(player, y)
if character == player.Character then
part.CFrame = CFrame.new(part.Position) * CFrame.Angles(0, y, 0)
end
end)
And here is the local script that sends the updated y value to the server:
local GetCamAngle
RotateChair.OnClientEvent:Connect(function(Sitting)
camera.CameraSubject = humanoid
if Sitting == true then
cancel_throw()
GetCamAngle = camera:GetPropertyChangedSignal("CFrame"):Connect(function()
if humanoid.Sit == true then
local cameraCFrame = camera.CFrame.LookVector
local y = math.atan2(cameraCFrame.Z, -cameraCFrame.X)
y = math.rad(math.deg(y)+90)
y = math.floor(y*mult)/mult
RotateChair:FireServer(y)
else
stopSittingAnim()
GetCamAngle:Disconnect()
end
end)
else
if GetCamAngle ~= nil and humanoid.Sit == false then
GetCamAngle:Disconnect()
end
end
end)
Any help is appreciated!