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

how can I make this platform follow the player?

I made a platform that remains a certain distance under the HumanoidRootPart so the player can walk through the air.

while true do
	wait()
			--flyer.Position = char.HumanoidRootPart.Position - Vector3.new(0,3.129,0)
		flyer.CFrame = char.HumanoidRootPart.CFrame - Vector3.new(0,3.129,0)
				
end

The problem is, the loop moves too slow to keep up with how fast the player walks. How can I work around this?

1 answer

✓ Accepted answer

The problem with your loop is probably the wait(). The default wait time in studio is about 0.03 seconds, and considering a frame in a 60fps environment is about 0.016 seconds, your loop is only running about 30 times per second. There is a way to make this faster though.

Introducing,Heartbeat. This is an event that fires after the physics simulation has finished, making it wait only about 0.016 seconds per wait call. This will essentially double you loop speed.

To use it, simply replace your normal wait() with a:

game:GetService("RunService").Heartbeat:Wait()

Note: Heartbeat fires dependant on how many frames your computer is rendering per second. If your computer can only do 30 frames per second, Heartbeat will only fire 30 times per second.

Hope this helps! If you have any further questions feel free to comment or look things up on the devforum.

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