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

I need help with positions and things?

So I want a crystal to follow above your head, it works, but it is jumpy and stuff. I want it to be really smooth. If you can help me fix this thank you. Btw, this is a local script before you say anything.

function MoveCrystal()
	local character = game.Players.LocalPlayer.Character
	local crystal = workspace.Crystal
	local head = character["Head"]
	local objectSpace = CFrame.new(0, 2, 0)
	local worldSpace = head.CFrame:toWorldSpace(objectSpace)
	crystal.CFrame = worldSpace
end

while wait() do
	MoveCrystal()
end

1 answer

✓ Accepted answer

Right now, you're using a wait(). That wait time can be smooth sometimes, but since you're saying it isn't, you could either use while wait(-1) do, or you could use this script instead of the while:

game:GetService('RunService').RenderStepped:connect(function()
	MoveCrystal()
end)

Stepped is like a while wait() do, but it repeats every 60th of a second!

EDIT: Didn't notice you said it was a localscript. Stepped is for serverscripts, and RenderStepped is for localscripts ;D

2 comments

0

wait(-1) will wait the same time as wait() or wait(0). The minimum wait time is about a 30th of a second.

0

Well well, anyways, renderstepped is shorter than wait, and I use it myself to make animations go smooth. Recommend you try it ;3

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