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

How can i move a part of a player to a certain position using cframe, such as the arm of a player?

Asked by 6 years ago

I'd like to start experimenting with cframe, but I have no clue where to start. I've looked at wiki's, and many tutorials. Although they all seem to be outdated, or make no sense to me. I've also studied other scripts that use cframe to animate players, although they were much too advanced for me. Could anyone link me to a useful article or tutorial, or if you have the time, explain how I can move/animate parts of a player using cframe.

(More specifically I would like to learn how to move a part from its existing position to another position in accordance to its current position. Such as rotating a part and moving it several units up from its current position.)

Any help would be much appreciated, thank you.

1 answer

Log in to vote
0
Answered by
Nep_Ryker 131
6 years ago
Edited 6 years ago

First, you would need to look and wait for the player to spawn or to "exist". So, to do that you would need to use WaitForChild(). The most common mistake that people make is using FindFirstChild() and end up not getting the script to work because the character didn't exist yet.

This is one of my scripts and I'm gonna show it as an example: Also, check if the part exists.

function getPlayer(player)
    if player and player.Character then
        local humanoidRootPart = player.Character:WaitForChild("HumanoidRootPart")
        if humanoidRootPart then -- Checking if it exists, extra safe.
            -- Nothing yet
        end
    end
end

After waiting for that specific part, you would then use CFrame to properly teleport the Player. ( Not killing them ). So to do that you would do this:

local baseplate = game.Workspace.Baseplate
humanoidRootPart.CFrame = CFrame.new(baseplate.Position + Vector3.new(0,3,0)) 

Becareful when using CFrame, since it will teleport to the exact position you tell it to, so if there's a floor. The player will end up getting stuck in the floor. So add like a bit of Y value like I did.

CFrame lets you teleport a part and whatever is attached to the part that you teleported, will follow the part as well. Hope this helped.

0
But if you really want to just teleport the Arm, just get the arm and set the position to whatever you would like. Player might not die. Nep_Ryker 131 — 6y
0
Thank you, but this dosnt really answer my question. EtherealTrin 45 — 6y
0
Why not just use the animation editor :p Nep_Ryker 131 — 6y
Ad

Answer this question