I am not sure on how to use the RenderStepped function. I am not sure if I would have to use a wait or what but I though RenderStepped was a type of "wait()".
local Plr = game.Players.LocalPlayer local Part = game.ReplicatedStorage:WaitForChild("DisplayInfo"):Clone() Part.Parent = Plr.Character Part.CanCollide = false game:GetService("RunService").RenderStepped:connect(function() --Instead of this, I used a wait and it worked fine. It is my first time using this function. Part.CFrame = Plr.Character:WaitForChild("Head").CFrame * CFrame.new(0,3,0) Part.Anchored = true end
Wiki entry for the RunService.
Every ~1/60 of a second, a render update happens. Each render update, a bunch of code is run, namely the code involved with rendering the 3D environment on your screen. There's other stuff too, but that is the "rendering" that the name refers to.
If you want to run your own code on each render update, you have 2 options. You can connect to an event, which is the "old way:"
RunService.RenderStepped:connect(function(step) -- code goes here -- here "step" is the exact amount of time since the last render update end)
Or you can bind a callback, which is the "new way:"
local function onRenderStepped() -- code goes here end RunService:BindToRenderStepped("renderFunctionName", Enum.RenderPriority.First.Value, onRenderStepped) -- corresponding unbind: RunService:UnbindFromRenderStepped("renderFunctionName")
The new way is basically a fancier version of the old way, they do the same thing but the new way is easier and safer to use, in my opinion.
The render priority enum determines in what order render functions are executed. Higher numbers mean executed later. The wiki entry for the RenderPriority enum is here.
The functions you bind to render stepped are gonna be called really fast, faster than you can make the be called in a normal loop, because wait() can only delay for as little as 1/30 of a second. Make sure whatever functions you bind to render stepped are really fast, because if they aren't, they will actually slow down render updates, making your game lag like crazy.
I want to emphasize that these functions are called only on render updates, not on a 1/60 of a second loop. If no render update happens, your function wont be called. This means if the game is minimized, you wont get render updates.
I hope this helps!