How do you rotate a person's arm while they are in a seat?

Is there any way to rotate a person’s arm when they are in a seat? I know you can do so with animations, but how about with a script? I want to make it so that when they are seated and I spawn in a weapon on their hand, it rotates the arm up so it looks like they are holding it.

Is there a way to do it while they are seated (and on the Server side)?

local rightArm = player.Character["RightUpperArm"].RightShoulder;

local rightArmC0 = rightArm.C0;
local rightArmC1 = rightArm.C1;

if rightArmC0 and rightArmC1 then
    rightArmC0.CFrame = rightArmC0.CFrame * CFrame.Angles(0, math.rad(45), 0); -- CFrame not CFrame error?
end

When you insert a part you should be able to add a “seat” part. Once added you can adjust it to whatever size you want it. This “seat” part already has a pre-animation that will rotate the players arms up when they sit down. There is no scripting needed. Hope this helps!

Well. I want to make it so that not everyone’s arms are rotated up when they’re sitting in a Seat part. I only want to make specific players rotate their arms up with a script. If that makes any sense.

Are you referring to seats like in those vibe games? Some seats make your arms go up and some don’t?

Try replacing Player at the top with CFrame.

I guess so. I only want the Server to decide whether or not that person in the Seat will put their arms up.

For example:

There are 2 Seats.

Player1 is sitting in Seat1.
Player2 is sitting in Seat2.

Server gives Player1 a gun.

Rotate Player1’s arm up 45 degrees. (Player2’s arm is still down)

Server takes away Player1’s gun.

Rotate Player1’s arm down 45 degrees. (Player2’s arm is still down)

Server gives Player2 a gun.

Rotate Player 2’s arm up 45 degrees (Player1’s arm is still down)

and etc…

I made this script, it’s a bit buggy but it works :smiley:
Insert into StarterCharacterScripts

local char = script.Parent
local player = game.Players:GetPlayerFromCharacter(char)
local hum = char:findFirstChild("Humanoid")

char.ChildAdded:Connect(function(child)
	if child:IsA("Tool") then
		if hum.SeatPart ~= nil then
			local seat = hum.SeatPart
			hum.Sit = false
			wait(0.1)
			while hum.SeatPart == nil do
				wait()
				seat:Sit(hum)
			end
		end
	end
end)

char.ChildRemoved:Connect(function(child)
	if child:IsA("Tool") then
		if hum.SeatPart ~= nil then
			local seat = hum.SeatPart
			hum.Sit = false
			wait(0.1)
			while hum.SeatPart == nil do
				wait()
				seat:Sit(hum)
			end
		end
	end
end)
1 Like

Temporary solution for now, I guess. I’m hoping someone can post a more efficient way of doing this.

The gun isn’t a tool, btw, it’s a MeshPart. xD

The arm goes up if it’s a tool, but doesn’t if it’s a MeshPart.

I didn’t know it was a MeshPart. However I’d still say your best bet is with animations. I’ve made a sample script of what it would be like. (Script goes into StarterCharacterScripts)

local char = script.Parent
local player = game.Players:GetPlayerFromCharacter(char)
local hum = char:FindFirstChild("Humanoid")

local animtrack = Instance.new("Animation", script)
local rigtype = hum.RigType

if rigtype == Enum.HumanoidRigType.R6 then
	animtrack.AnimationId = "rbxassetid://"..8462963586
	anim = hum.Animator:LoadAnimation(animtrack)
elseif rigtype == Enum.HumanoidRigType.R15 then
	animtrack.AnimationId = "rbxassetid://"..8462973172
	anim = hum.Animator:LoadAnimation(animtrack)
end

char.ChildAdded:Connect(function(child)
	print(child)
	if child:IsA("MeshPart") or child:IsA("Tool") then
		if hum.SeatPart ~= nil then
			anim:Play()
		end
	end
end)

char.ChildRemoved:Connect(function(child)
	print(child)
	if child:IsA("MeshPart") or child:IsA("Tool") then
		if hum.SeatPart ~= nil then
			anim:Stop()
		end
	end
end)

hum.Changed:Connect(function(change)
	if change == "SeatPart" then
		if hum.SeatPart == nil then
			anim:Stop()
		end
	end
end)

Because the character is animated by default, you can’t simply rotate the arm by setting the CFrame, as that can separate the arm from the body.