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

How do I make my arm swing back and forth?

Asked by
jqrx 0
8 years ago

I simply don't know the math to make my arm swing back on forth. I desperately need help. Line 18: Char 34

local char = game:service'Players'.LocalPlayer.Character
local torso = char["Torso"]
local larm = char["Left Arm"]
------------------------------------------------------------
function Lerp(origin,goal,time)
    return origin:lerp(goal,time)
end
function Weld(p0,p1,cf)
    local weld = Instance.new("Weld")
    weld.Part0 = p0
    weld.Part1 = p1
    weld.Parent = weld.Part0
    weld.C0 = cf
end
-----------------------------------------------------------------
Weld(larm,torso,larm.CFrame)
game:service'RunService'.RenderStepped:connect(function()
    larm.Weld.C0 = Lerp(larm.Weld.C0,whatDoIPutHere,0.1)
end)

Help would be appreciated.

2 answers

Log in to vote
4
Answered by
1waffle1 2908 Trusted Badge of Merit Moderation Voter Community Moderator
8 years ago

The old way of doing animations was to set loops on motors. You can use Torso["Left Shoulder"].DesiredAngle if you remove anything animation-related from a character if you want to do things that way. For the left shoulder, 0 is down, 1.57 is backward, -1.57 is forward, 3.14 is up.

If you want to do things the new way, you should create an animation.

If you want to use math, well...

local player=game.Players.LocalPlayer
local larm=(player.Character or player.CharacterAdded:wait()):WaitForChild("Torso"):WaitForChild("Left Shoulder")

local t=0
--larm.C1=CFrame.new(.5,.5,0)*CFrame.Angles(0,-math.pi/2,0)
game:GetService("RunService").RenderStepped:connect(function(d)
    t=t+d
    larm.C0=CFrame.new(-1,.5,0)*CFrame.Angles(-math.pi/2,-math.pi/2,math.pi/2*(math.sin(t)-1))
end)
Ad
Log in to vote
0
Answered by 8 years ago

you seem to be lost in welding as much as I once was. A great video on this https://www.youtube.com/watch?v=eBMWLUAgNMs Basically tells you how to weld , or introduces welding to you. You did well but you may want to have it anchored before you even make it parent and then after unanchor it. Animation can also work if you know how to use it, but I do not know how to use it at all. Anyways the video does help quite abit on welding.

0
The elitist people on this site really love to downvote.. scottmike0 40 — 8y

Answer this question