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

How can i set boundary when right arm following Cursor?

Asked by 4 years ago

With this way right arm folows the cursor even behind of the character. How can i set boundary for limiting arm movement?

local armOffset = character.UpperTorso.CFrame:Inverse() * character.RightUpperArm.CFrame
local armWeld = Instance.new("Weld")
armWeld.Part0 = character.UpperTorso
armWeld.Part1 = character.RightUpperArm
armWeld.Parent = character

RunService.Heartbeat:Connect(function()
    local cframe = CFrame.new(character.UpperTorso.Position, mouse.Hit.Position) * CFrame.Angles(math.pi/2, 0, 0)
    armWeld.C0 = armOffset * character.UpperTorso.CFrame:toObjectSpace(cframe)
end)

Answer this question