Hey Developers, I’m creating certain UIS that involve viewportframes and I was wondering how I can make them spin 360 looped.
Spin the object inside the frame.
RunService.RenderStepped:Connect(function(Delta)
Object.CFrame = Object.CFrame * CFrame.Angles(0, math.rad(10 * Delta), 0)
end)
2 Questions.
This will work with models?
Does it get inserted into the model or out of the model?
It will probably work with models. You can put the script into the model that’s in the viewport
local Model = script.Parent
RunService.RenderStepped:Connect(function(Delta)
Model:SetPrimaryPartCFrame(Model:GetPrimaryPartCFrame() * CFrame.Angles(0, math.rad(10 * Delta), 0))
end)
I tried it with a character model that’s in a viewport and I defined RunService and it still won’t seem to work any other things that I could do?
NEVER rotate the model in a ViewportFrame. Always try to rotate the ViewportFrame’s Camera instead. Rotating the camera of a ViewportFrame is less expensive than rotating the model. Please check the Notes / Performance section of the ViewportFrame GUI article on the Developer Hub.
Additionally, do not use scripts for Guis, use LocalScripts. This is one reason as to why your code isn’t functioning correctly. Guis are user interfaces and user interfaces are primarily a client entity, so they should likewise also be controlled by LocalScripts. I only discovered this because you happened to screenshot your Studio tabs above.
