Reputation: 11
I'm trying to only change the player's torso's CFrame to add 1 to the Y value every second for 10 seconds.
Upvotes: 1
Views: 2665
Reputation: 56
local torso = game.Players.LocalPlayer.Character.Torso
--> change that to get the player's torso however you want
for i = 1, 10 do --> iterate (loop) from one to ten
torso.CFrame = torso.CFrame + Vector3.new(0,1,0)
--> I think that is what you're looking for
wait(1)
end --> go back to the top of the loop, until i has reached 10
print("done")
Other things to keep in mind:
1) roblox characters have a "HumanoidRootPart" and animations can act weird if you set positions by using torsos. (not normally an issue)
2) gravity will keep the player down unless the part is anchored,
3) smaller waits are smoother. When you are comfortable with for loops and functions) look up "RunService" on the wiki. Using Stepped Events makes things very smooth.
local torso = game.Players.LocalPlayer.Character.Torso
for i = 1, 3000 do
torso.CFrame = torso.CFrame + Vector3.new(0,0.03,0)
wait() --> the default wait is about 0.03 seconds
end
print("done")
Upvotes: 1