Have a shop that spins my models, am wondering if GetService.HeartBeat is recommended to use or potentially game breaking?

  1. What do you want to achieve?
    I have a shop GUI script that loops through a folder with models I want to display in my shop, creates a CFrame, camera, and parents it to the ViewportFrame, and displays the model. I wanted the model to spin around, and researched that it is recommended to spin the camera rather then the model instead.
    I searched around, and inside the loop that goes through each model in my folder and does the code to display it on my GUI, I have this which I copied from a video on how to make it spin.
local c = 0
game:GetService("RunService").Heartbeat:Connect(function()
		local cframe = modelPreview.CFrame * CFrame.Angles(0, math.rad(c), 0) * CFrame.new(0, 0, -4) 
		cframe = CFrame.new(cframe.p, modelPreview.Position)
		vf.CurrentCamera.CFrame = cframe;
		if c < 360 then
			if c < 90 then
				c = c + 1
			elseif c > 90 and c < 270 then
				c = c + 2
			else
				c = c + 1
			end
		elseif c >= 360 then
			c = 0
		end
		
	end)
  1. What is the issue?
    Is using this method heavy on the server? The reason I have the weird if c < 360 and c > 90 etc… is because I want the front of the model to turn slowly, and once it reaches a certain angle to spin faster back until it shows the front of the model, which then it slows down to show.

Am I putting a lot of stress on the server through this method? Any better recommended methods out there?

Probably not. While there are definately ways to optimize this (using this on the client to reduce server load, using the same camera for all the viewport frames, only doing it when actually being shown), it’s probably fine, as there will be other things that are 10 times more intensive running than changing some numbers.

2 Likes

Wow, I totally forgot I could handle this locally instead. Thank you for the reply!