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

Is there a way to set CFrame of "Stand" with Using Heartbeat or RenderStepped?

Asked by 5 years ago

game:GetService("RunService").RenderStepped:connect(function() StandHR.CFrame = HR.CFrame * CFrame.new(0, 0, 2.5) end)

--- HR is a HumanoidRootPart

So if there is anyway to clone this and being seeable by all people?

0
Make it not a local script...? DeceptiveCaster 3761 — 5y
0
but if I will then it says that Heartbeat/RenderStepped can be run only from Local script wiktormont 14 — 5y
0
If you want to replicate for other clients you'll have to unanchor the "StandHR" part and on a server script set it's network ownership to the player using it. hellmatic 1523 — 5y

1 answer

Log in to vote
0
Answered by 5 years ago
Edited 5 years ago

You can use a while loop to replace the RenderStepped function, though it'll be about half as fast so you should double the rate at which it moves. You can use either of the below methods to accomplish this.

Note that to replicate to other players, it'll have to be in a server script instead of a localscript. ``` while true do StandHR.CFrame = HR.CFrame * CFrame.new(0, 0, 2.5) wait() end

-- OR

while wait() do StandHR.CFrame = HR.CFrame * CFrame.new(0, 0, 2.5) end ```

However, based on the context, a while loop - and even the heartbeat and renderstepped methods you were using before - probably wouldn't be very performance-friendly for your game, likely causing a lot of lag.

An alternative can be found in BodyMovers, which can be found here. What you should probably use is a BodyVelocity, which keeps a part in the air (unaffected by gravity) and moves it at a constant rate. Keep in mind this is totally optional, and if you have better success with the previous method, you can stick to it.

Ad

Answer this question