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

How to move a position of a player?

Asked by 5 years ago

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

Log in to vote
1
Answered by
KDarren12 705 Donator Moderation Voter
5 years ago
Edited 5 years ago

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

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 richboifexekappa 89 — 5y
0
That is why I said to learn Lerping. KDarren12 705 — 5y
0
:Lerp() can be used for CFrame, but it is quite tricky. KDarren12 705 — 5y
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) richboifexekappa 89 — 5y
View all comments (3 more)
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. KDarren12 705 — 5y
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. KDarren12 705 — 5y
0
but when I tried to use it it sids Torso is not a valid member of the model willywillycow 50 — 3y
Ad

Answer this question