#make the player's arm move according to the position of the mouse

1 messages · Page 1 of 1 (latest)

low bane
#

i want the player's right arm to point to where the player's mouse is. i think the best solution is to use the "right shoulder" motor6d but with my current system it looks super messed up and i can't figure this out

forgive the bad formatting, the script is in the prototype phase

--local UserInputService = game:GetService("UserInputService")
local Players = game:GetService("Players")
local RunService = game:GetService("RunService")

local tool = script.Parent
local equip_connection: RBXScriptConnection
local animation = tool:WaitForChild("freeze_right_arm")

local player = Players.LocalPlayer

local character = player.Character or player.CharacterAdded:Wait()
local humanoid: Humanoid = character:WaitForChild("Humanoid")

local animator: Animator = humanoid:WaitForChild("Animator")
local animation_track = animator:LoadAnimation(animation)

local torso: Part = character:WaitForChild("Torso")
local right_arm: Part = character:WaitForChild("Right Arm")
local right_shoulder_m6d: Motor6D = torso:WaitForChild("Right Shoulder")

local mouse: Mouse = player:GetMouse()

local right_shoulder_initial_c0 = right_shoulder_m6d.C0

animation_track.Priority = Enum.AnimationPriority.Action

local function point_arm()
    
    local mouse_pos = mouse.Hit.Position
    local right_arm_pos = right_arm.Position
    
    local point_to_pos = CFrame.lookAt(right_arm_pos, mouse_pos)
    local x, y, z = point_to_pos:ToOrientation()
    
    right_shoulder_m6d.C0 = right_shoulder_initial_c0 * CFrame.Angles(x, y, z)
    
end

tool.Equipped:Connect(function()
    
    animation_track:Play()
    equip_connection = RunService.RenderStepped:Connect(point_arm)
    
end)

tool.Unequipped:Connect(function()
    
    animation_track:Stop()
    if (equip_connection) then
        
        equip_connection:Disconnect()
        equip_connection = nil
        right_shoulder_m6d.C0 = right_shoulder_initial_c0
        
    end
    
end)
real nymph
#

To do something like this it's gonna be more then just the shoulder, but out of arguments sake since I've been wrong before, have you tried other arm parts , like the hand?

low bane
#

it only has the arms, legs, torso and head. with rightshoulder i mean the motor6d inside torso

#

sorry if its unclear in the original message

real nymph
#

Oh, I'm not sure given directionality this would be possible without it being funky in R6, possibly using the part directly and not the motor6D, but honestly you'd probably need a custom character

low bane
#

ill look into it

low bane
#

using the part directly makes the character tweak the hell out, it starts flinging you around

tacit crestBOT
#

studio** You are now Level 1! **studio

mighty raptor
#

(hiiiiii twin :D)

low bane
#

dude spawned literally out of nowhere

mighty raptor
#

yeah, that's how we roll sometimes...

low bane