Cube Rotation Game

I pasted that script in but it doesn’t seem to be working. I think by using Velocity and RotVelocity, it’s taking the LinearVelocity and AngularVelocity vectors aspect out of it. It could also be that I’m just doing it wrong. With the script I pasted above, the properties were working fine (not sure if these are the same properties that weren’t working for you). I think my next step is transitioning the code into a repeat until loop for 90 seconds or until everyone on the cube falls off.

I’ll do some testing on my own about this. I’ll let you know about a successful result.

local RunService = game:GetService("RunService")

local Part = script.Parent -- Change this to the location of the part(s)
local function UpdatePart(part: BasePart, rotVelocity: Vector3): ()
	if (typeof(part) == "Instance") then
		if (part:IsA("BasePart")) then
			local Atttachment = part:FindFirstChildWhichIsA("Attachment")
			if (not Atttachment) then
				Atttachment = Instance.new("Attachment", part)
			end
			
			local LinearVelocity = part:FindFirstChildWhichIsA("LinearVelocity")
			if (LinearVelocity) then
				LinearVelocity.VectorVelocity = Vector3.new()
			else
				LinearVelocity = Instance.new("LinearVelocity", part)
				LinearVelocity.Attachment0 = Atttachment
				LinearVelocity.MaxForce = math.huge
				LinearVelocity.VectorVelocity = Vector3.new()
			end
			if (typeof(rotVelocity) == "Vector3") then
				local AngularVelocity = part:FindFirstChildWhichIsA("AngularVelocity")
				if (AngularVelocity) then
					AngularVelocity.AngularVelocity = rotVelocity
				else
					AngularVelocity = Instance.new("AngularVelocity", part)
					AngularVelocity.Attachment0 = Atttachment
					AngularVelocity.AngularVelocity = rotVelocity
					AngularVelocity.MaxTorque = math.huge
				end
			end
		end
		for i, v in next, part:GetChildren() do
			UpdatePart(v, rotVelocity)
		end
	elseif (typeof(part) == "table") then
		for i, v in next, part do
			if (typeof(v) == "Instance" and v:IsA("BasePart")) then
				UpdatePart(v)
			end
		end
	end
end

coroutine.wrap(function()
	while (true) do
		UpdatePart(Part, Vector3.new(math.random(-30, 30)/100, math.random(-30, 30)/100, math.random(-30, 30)/100))
		task.wait(5)
	end
end)()

There you go. Your method of Linear/AngularVelocity instances in a part seemed the way to go. Apologies for my misunderstanding.

That script supports multiple parts, and not just one. So you could have a folder of parts of which will specifically rotate.

This will also automatically create the instances needed to get this working. So all you have to do is just create parts, the script will do the rest.

Wow, thank you so much! Really appreciate it.

1 Like

Of course, hope your game turns out nice.