Currently I’m attempting to make a spinning “Blade” type of thing, the spinning blades are purely for aesthetics and serve no actual purpose.
The main part of the spinner has a hinge constraint that has angular velocity to spin the blades. I’ve tried messing around with mass settings, different constraints, torque, even made the spinning parts invisible to see if the lag had to do with rendering.
Each spinning part has its own constraint, if that is the primary problem what could fix this? I’ve attempted to use align orientation but I couldn’t get that to function with the spinning blades as they move and need to change orientation on there own.
Attached is a gif of me deleting the spinners the game speeding up.
This is most likely due to you putting a lot of stress on the server with the amount of physics that are happening. You should try setting the network owner or making a LocalScript to handle rotations.
If the lag is physics-based as it seems to be, you could try using welds and updating the CFrame of the welds using RunService. This isn’t necessarily light code, but it shouldn’t cause visual lag like you’re seeing.
In case you aren’t familiar with welds, you can create a weld using Instance.new(“Weld”,workspace), then use it the same as you’d use weld constraints. You can’t use weld constraints for this, though, because they don’t have a CFrame property you can directly edit like welds do. For the example script, I’ll be parenting the welds to the spinner blades themselves, assuming they’re separate parts from the black base (it’s kind of hard to tell in the video, so sorry if this is wrong).
There’s a bit of CFrame math involved, but it isn’t much. In order to keep it all in a single script, it’s best to use a loop and spin all of them from the same script. This would look something like:
--put script in the same parent as all the cursed spinner models
local rs = game:GetService("RunService")
local spinners = script.Parent:GetChildren()
local offset = Vector3.new(0,0.25,0) --positional offset between black base and blades
local rate = 2 --speed of spinners
rs.Heartbeat:Connect(function()
n = n + rate
for i,v in pairs(spinners) do
local spinner = v:FindFirstChild("cursed_spinner")
if spinner then
local weld = spinner:FindFirstChildWhichIsA("Weld")
if weld then
weld.C0 = CFrame.new() * CFrame.Angles(0,math.rad(n),0) + offset
end
end
end
end)
You’ll want to make sure none of the welded parts are anchored and that the spinners are CanCollide = false. Also note that while this method should work for reducing visual lag, it may or may not be a bit harsh on the computing (I can’t say for sure).
If you’re confused on anything, feel free to let me know and I can elaborate and help out a bit.
Oh, I appreciate the advice, but I was just telling how to get a weld into workspace from Studio. I don’t think it pops up when you right-click for Insert Object, my bad if I’m wrong on that. Still, thanks, that post is correct in that you should write the extra few lines when frequently creating instances with code to reduce delay time.