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

How do I make a gun holding animation follow the cursor?

Asked by
di5z 11
4 years ago
Edited 4 years ago

I found this snippet of code which I modified to work with both hands

repeat wait() until game.Players.LocalPlayer ~= nil local Players = game:GetService("Players") local RunService = game:GetService("RunService")

local plr = Players.LocalPlayer local char = plr.Character local mouse = plr:GetMouse()

local armOffset = char.UpperTorso.CFrame:Inverse() * char.RightUpperArm.CFrame local armOffset2 = char.UpperTorso.CFrame:Inverse() * char.LeftUpperArm.CFrame

local armWeld = Instance.new("Weld") armWeld.Part0 = char.UpperTorso armWeld.Part1 = char.RightUpperArm armWeld.Parent = char local armWeld2 = Instance.new("Weld") armWeld2.Part0 = char.UpperTorso armWeld2.Part1 = char.LeftUpperArm armWeld2.Parent = char

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

example: here but the position of the left arm is just a few centimeters behind the right arm. How could I make the arm reach just a little bit further? Thank you! I'm new to welding.

0
the heck is heartbeat Jakob_Cashy 79 — 4y
0
@Jakob_Cashy please say something constructive, dont say "wHaT ThE fRIck iS tHAt" WideSteal321 773 — 4y

Answer this question