hii!! so i have this script and it isn’t working. its basically a viewport frame and when your mouse hovers over it, it spins. but when ur mouse leaves the gui, then the part spinning freezes. if anyone could help tell me what’s wrong with this script i would rlly appreciate it!! <33
local spinning = false
local frame = script.Parent.Parent
local part = script.Parent
local partSpeed = 0.01
frame.MouseEnter:Connect(function()
spinning = true
end)
frame.MouseLeave:Connect(function()
spinning = false
end)
while true do
if spinning then
part.CFrame = part.CFrame * CFrame.Angles(0,partSpeed,0)
end
end

It’s a server script.
Could be the issue, but I could be wrong.
Delete the old script, create a localscript INSIDE THE SCREENGUI, NOT THE PART.
Then, enter this as the source:
local ROT_INCREMENT = 0.01 -- Rotation Increment
--
local Gui = script.Parent
local Viewport = Gui:WaitForChild("ViewportFrame")
local Object = Viewport:WaitForChild("Part")
local Spinning = false
Viewport.MouseEnter:Connect(function()
Spinning = true
end)
Viewport.MouseLeave:Connect(function()
Spinning = false
end)
while true do
if Spinning then
Object.CFrame *= CFrame.Angles(0, ROT_INCREMENT, 0)
end
task.wait() -- No wait was added, so it would most likely crash.
end
I am unsure if you can edit viewport objects, but do please look into it.
I highly don’t recommend rotating the part itself since the viewport gets updated every time the children of the viewport gets updated which can be pretty resource consuming especially if there are a lot of these viewports. I would recommend rotating the camera around the part instead of rotating the part itself.
wow!! it worked!! thank u sm!! i rlly appreciate it!! helped me sm and taught me a few things aswell!! thank u sm once again. have an amazing rest of ur day! stay safe <33