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

Why won't this script rotate the part (Arm) to my mouse?

Asked by 5 years ago

Hello! I have a script that is supposed to rotate my arms to the z axis, and this is a modified version of what I had before. This in theory should work right? It doesn't make sense to me. Can one of you help me on this issue I've been wrapping my head around? -Thanks!, This is a Local Script inside of the tool:

local plr = game.Players.LocalPlayer
local Character = plr.Character or plr.CharacterAdded:wait()
local Mouse = plr:GetMouse()
local prev_mousehit
local tool = script.Parent.Parent.M4

tool.Equipped:Connect(function()
Mouse.Move:Connect(function()
    local Arm1 = Character:FindFirstChild("UpperLeftArm")
local Arm2 = Character:FindFirstChild("UpperRightArm")
    if Mouse.Hit.p ~= prev_mousehit then
        Arm1.CFrame = Arm1.CFrame.new(Arm1.Position, Vector3.new(Mouse.Hit.p.z))
        Arm2.CFrame = Arm1.CFrame.new(Arm1.Position, Vector3.new(Mouse.Hit.p.z))
    prev_mousehit = Mouse.Hit.p
    end
  end)
end)

Answer this question