Roblox Studio如何仅更改部件CFrame的Y值

时间:2018-01-25 22:56:49

标签: lua roblox

我试图只改变玩家的躯干CFrame,每秒加1到Y值,持续10秒。

1 个答案:

答案 0 :(得分:1)

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")

要记住的其他事项:

1)roblox角色有一个" HumanoidRootPart"如果你通过使用躯干设置位置,动画可能会很奇怪。 (通常不是问题)

2)重力将使玩家保持向下,除非该部分被锚定,

3)较小的等待更顺畅。当您熟悉for循环和函数时)查找" RunService"在维基上。使用Stepped Events可以使事情变得非常顺利。

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")