I am trying to make an animation for my game but it isn’t working, so instead I would like to use CFrame instead of making the animation itself.
Any idea how I would do that? I have tried the code below but that didn’t work.
print("starting 3")
wait(1)
print("2")
wait(1)
print("1")
wait(1)
print("STARTED")
for wow = 0, 1, 0.01 do
game.Players.LocalPlayer.Character["Left Arm"].CFrame = game.Players.LocalPlayer.Character["Left Arm"].CFrame:Lerp(2, 2, 2, wow)
end
Yes, I am using the script for R6. I fixed it up but now my whole body moves with it, not just my arm.
for wow = 0, 1, 0.01 do
game.Players.LocalPlayer.Character["Left Arm"].CFrame = game.Players.LocalPlayer.Character["Left Arm"].CFrame:Lerp(CFrame.new(4,4,4), wow)
end
R15 and R6 have different character descendents.So basically you have to make sure the part is there in character to make it work.
How to fix
Now lerp function is basically not much recommended by many developers.If you want to change the position using Vector3.new(x,y,z) if you want to rotate the arm or somewhat like that
use CFrame.Angles() or Orirentation if you want in a specific angle.To get the sides of a part you can use CFrame.LookVector/UpVector/RightVector*x
Better way for animations
R15 animations don’t support or work for R6. So if you want an animation make sure your doing in the correct one (R6/R15) so you don’t mess up.If its still not working, check the output if it says any error related to R6 or R15 then you have messed up in it.
If your feeling easier to do with cframe then you can but its alot laggy and bigger way for doing it
Its because the arm is welded to your body so it won’t fall apart, so your character is like a real human being character.Now if you change the cframe character will move it,you can use animations or rotation for avoiding this issue.
There is a way but unwelding wouldn’t be that good as you cannot stick the arm together perfectly fine again.If you unweld the arm it falls apart so you have to anchor it, if you anchor it your character arm won’t be there with body.Then its like a zombie game with one arm, and if many people play many arms will be fallen and it will cause extra lag for low end users.
Alright, thank you! I appreciate it. One more thing if you don’t mind. Is this correct?
local player = game:GetService("Players")
local localplr = player.LocalPlayer
local char = localplr.Character
char["Right Arm"].CFrame.Angles(Vector3.new(1,1,1))
local player = game:GetService("Players")
local localplr = player.LocalPlayer
local char = localplr.Character or localplr.CharacterAdded:Wait() -- if the player's character still not loaded, it will wait until it is loaded
char["Right Arm"].CFrame.Angles(Vector3.new(1,1,1)) -- Angles is not a function [?]
Yes the variables are correct but you won’t give vector3 values in cframe.angles(), you should write in radians.If you know angles like 45 degress its easier, you just need to use math.deg()
Script:
local playerservice = game:GetService("Players")
local player = player.LocalPlayer
local character = player.Character
local function movearm(angle) -- Recieved information or arguements
if character:IsLoaded() then
character:FirstFirstChild("Right Arm").CFrame = character:FirstFirstChild("Right Arm").CFrame * CFrame.Angles(angle,angle,angle)
end
end)
local chosenangle = math.deg(45) -- Your chosen angle
-- If you want to fire the function say
movearm(chosenangle)
-- It fires the function with the information we sent to it
If you think this is hard to understand, you can refer the CFrame here