Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
2

Arm Pointing At Mouse.hit.p?

Asked by 9 years ago

I've been trying to get the mouse and head to both look at the mouse, the head works but I've tried a lot of things to get the arms to move. The arm is backwards and such. This script also kills you once when you test it I have no clue why that is happening. This is a localscript in starterpack. Please help and explain what is wrong!

repeat wait() until game.Players.LocalPlayer
local Player = game.Players.LocalPlayer
repeat wait() until Player.Character
local Character = Player.Character
repeat wait() until Character:FindFirstChild("Torso")

local Mouse = Player:GetMouse()
local Camera = game.Workspace.CurrentCamera
local Torso = Character:FindFirstChild("Torso")

for i, v in pairs(Character:GetChildren()) do
    if v:IsA("BasePart") and v.Name == "Left Arm" or v.Name == "Right Arm" then
        local arm = v:Clone()
        arm.Parent = Camera
        local weld = Instance.new("Motor6D", arm)
        weld.Part0 = arm
        weld.Part1 = v
    end
end

game:GetService("RunService").RenderStepped:connect(function()
    Mouse.TargetFilter = game.Workspace
    Torso.Neck.C1 = CFrame.new(0, 0, 0)
    Torso.Neck.C0 = CFrame.new(0, 1.5, 0) * CFrame.Angles(math.asin((Mouse.Hit.p - Mouse.Origin.p).unit.y), 0, 0)
    Torso["Left Shoulder"].C0 = CFrame.new(-1, 0.5, 0, -0, -0, -1, 0, 1, 0, 1, 0, 0) * CFrame.Angles(0, 0, (Mouse.Hit.p - Mouse.Origin.p).unit.y * math.tan(90))
end)
2
The only thing that needs modification is line 25** YellowoTide 1992 — 9y

1 answer

Log in to vote
0
Answered by 9 years ago

Well the script I WAS going to give you didn't really work. I'm not very good with welds or CFrames. I tried BodyGyros but they made my character flip out. Sorry.

Ad

Answer this question