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.
I made this script, it’s a bit buggy but it works
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)
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.