helllo. i never lerped any motor6d or anything else.
how would a script look like that simply makes the right arm move up and down ?
here’s a simple script:
-- Get references to the right arm and the humanoid
local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local rightArm = character:WaitForChild("Right Arm")
local humanoid = character:WaitForChild("Humanoid")
-- Define animation parameters
local armOriginalPosition = rightArm.C0
local targetPosition = CFrame.new(Vector3.new(0, 5, 0)) -- Adjust the Vector3 for the desired up position
local animationTime = 2 -- Time in seconds for the animation
-- Function to perform the lerp animation
local function LerpArm()
local startTime = tick()
while tick() - startTime < animationTime do
local deltaTime = tick() - startTime
local t = deltaTime / animationTime
local lerpedPosition = armOriginalPosition:Lerp(targetPosition, t)
rightArm.C0 = lerpedPosition
wait() -- Let the script yield briefly to avoid hogging resources
end
rightArm.C0 = targetPosition
end
-- Start the animation when the humanoid is alive
humanoid.Died:Connect(function()
rightArm.C0 = armOriginalPosition
end)
LerpArm() -- Start the lerp animation
Note: replace the Vector3.new(0, 5, 0)
in the targetPosition
variable with the desired position for the arm when it’s raised. Also, adjust the animationTime
variable to set the duration of the animation in seconds.
p.s this is a basic script
no no i need one for r15 im really sorry for not telling earlier ):
ohhh it’s alright, give me a moment
it’s slightly different for r15
-- Get references to the right arm and the humanoid
local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid")
local rightArm = character:WaitForChild("Right Arm")
-- Define animation parameters
local armOriginalC0 = rightArm.C0
local targetPosition = CFrame.new(Vector3.new(0, 5, 0)) -- Adjust the Vector3 for the desired up position
local animationTime = 2 -- Time in seconds for the animation
-- Function to perform the lerp animation
local function LerpArm()
local startTime = tick()
while tick() - startTime < animationTime do
local deltaTime = tick() - startTime
local t = deltaTime / animationTime
local lerpedPosition = armOriginalC0:Lerp(targetPosition, t)
rightArm.C0 = lerpedPosition
wait() -- Let the script yield briefly to avoid hogging resources
end
rightArm.C0 = targetPosition
end
-- Start the animation when the humanoid is alive
humanoid.Died:Connect(function()
rightArm.C0 = armOriginalC0
end)
LerpArm() -- Start the lerp animation
As before, replace Vector3.new(0, 5, 0)
with the desired position for the raised arm and adjust the animationTime
as needed.
Keep in mind that this script only animates the arm’s local transformation (C0
). For more complex animations, you might need to involve more body parts and utilize keyframes or animation tracks.
it doesnt animate when tool animated, its alright i will do it myself
That script will infinitely yield because there isn’t a Motor6D in R15 called “Right Arm
”
I think what you’re looking for is the “RightShoulder
” Motor6D which is located within “RightUpperArm
”
thank god we got that smart boi in here
oh yea you’re right, sorry
local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid")
local rightUpperArm = character:WaitForChild("RightUpperArm")
local rightShoulder = rightUpperArm:FindFirstChild("RightShoulder")
local originalC0 = rightShoulder.C0
local targetCFrame = CFrame.new(Vector3.new(0, 5, 0)) -- Adjust the Vector3 for the desired up position
local animationTime = 2
local function LerpArm()
local startTime = tick()
while tick() - startTime < animationTime do
local deltaTime = tick() - startTime
local t = deltaTime / animationTime
local lerpedCFrame = originalC0:Lerp(targetCFrame, t)
rightShoulder.C0 = lerpedCFrame
wait()
end
rightShoulder.C0 = targetCFrame
end
humanoid.Died:Connect(function()
rightShoulder.C0 = originalC0
end)
LerpArm()
thank you for correcting me
aight ill try that out right now thank you
it is supposed to be in a tool, therefore the character is script.partne.parent