Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How to move a position of a player?

How can i make it so when for e.g i want to do a roll, the player moves the body towards the goal in a way like real life works where it can be seen the movement of the person, or for e.g i want to kick someone in the head and launch them backwards and they get up to a point in the air and then fall down on the ground. I can't think of any way, if i just change the position of their rootpart it will look like the guy just teleported

1 answer

✓ Accepted answer

This can simply be done with CFrame. You cannot move the body parts of a player with .Position. Instead, you can do something like this:

local plr = game:GetService("Players").PlayerName -- Gets the player specified
wait(.1)
plr.Character.Torso.CFrame = plr.Character.Torso.CFrame + Vector3.new(vector1,vector2,vector3)

That code block is not very useful for when other players are in the game. Use this to enable this for every player that joins:

game:GetService("Players").PlayerAdded:connect(function(plr)
wait(1)
local char = plr.Character
char.Torso.CFrame = char.Torso.CFrame + Vector3.new(vector1,vector2,vector3)
end)

Or, if you wanted to get more advanced, you can learn how to Animate with CFrame. I'm just learning it and I don't have a grip on it yet. You can use this link to learn about Lerping

7 comments

0

It does the exact same thing that i'm trying not to do, it feels like the player randomly teleports to the location instead of it moving towards the location

0

That is why I said to learn Lerping.

0

:Lerp() can be used for CFrame, but it is quite tricky.

0

Lerping seems to do it for me but is there a specific reason you would prefer using lerp to animate stuff instead of an animation plugin (i don't mean the crappy roblox animation plugin but more of the sort of moon animation suite)

0

I use lerp because the game I play (Void Script Builder) doesn't use that, and I just find it easier to use lerp with welding and other parts.

0

I use lerp because the game I play (Void Script Builder) doesn't use that, and I just find it easier to use lerp with welding and other parts.

0

but when I tried to use it it sids Torso is not a valid member of the model

This discussion is preserved as it was. New answers, comments, and votes are closed.