while true do
wait(2.7)
script.Parent["Dial Switch Twisting Sharp Ticking 137 (SFX)"]:Play()
wait(.3)
local Part = script.Parent
for i = 1, 7 do
Part.Orientation += Vector3.new(0,2.5,0)
end
wait(.5)
script.Parent["Dial Switch Twisting Sharp Ticking 137 (SFX)"]:Play()
wait(.3)
for i = 1, 7 do
Part.Orientation += Vector3.new(0,2.5,0)
end
wait(.8)
script.Parent["Slight Woosh"]:Play()
local Num = 12
for i = Num, 0, -1 do
task.wait()
Part.Orientation += Vector3.new(0,25,0)
for _, Touching in workspace:GetPartsInPart(Part) do
if game.Players:GetPlayerFromCharacter(Touching.Parent) then
Touching.Parent.HumanoidRootPart.AssemblyLinearVelocity = (Part.CFrame.UpVector * 200) + (Part.CFrame.LookVector * 200)
end
end
end
end
I want to have multiple instances of this part as children of the script. I’m wanting to have all the parts rotate and spin in unison. How would this be achieved?
Hey there, I think I understood your question. You could try to do something like this. I apologize if this looks formatted wrong. I am still getting the hang of the DevForum way of inputting coding. Though let me know if this helps!
-- Functions
local function Spin(v)
while true do
wait(.005)
-- Insert your parameters for a spin.
for a = 0,360,1.8 do
-- This changes the object's starting position and which axis the object will spin. Change accordingly.
v.CFrame = CFrame.new(v.Position)*CFrame.fromEulerAnglesXYZ(math.rad(0), math.rad(a), math.rad(90))
wait(.001)
end
end
end
local function Rotate(v)
while true do
wait(.005)
-- Insert your parameters for a rotation.
for a = 0,360,1.8 do
-- This changes the object's starting position and which axis the object will spin. Change accordingly.
v.CFrame = CFrame.new(v.Position)*CFrame.fromEulerAnglesXYZ(math.rad(0), math.rad(a), math.rad(90))
wait(.001)
end
end
end
-- MultiThread (Coroutine Wrap) *Be careful not to use too many of these, this can cause lag and potential memory leaks*.
function MultiThread(func)
local wrap = coroutine.wrap(func)
wrap()
end
-- ///
-- Change the destination to where you want it. (...in BLAH... do)
for i, v in script:GetChildren() do
MultiThread(function()
Spin(v)
end)
MultiThread(function()
Rotate(v)
end)
end
Oh my bad. I forgot to update this post a while ago. The issue was fixed. Here’s what I ended up with:
local Parts = script:GetChildren() -- this gets a table of parts
while true do
wait(3)
for i , part in ipairs(Parts) do
spawn(function()
script.UnionAudio.Click:Play()
for i = 1, 7 do
part.Orientation += Vector3.new(0,2.5,0)
end
end)
end
wait(.8)
for i , part in ipairs(Parts) do
spawn(function()
script.UnionAudio.Click:Play()
for i = 1, 7 do
part.Orientation += Vector3.new(0,2.5,0)
end
end)
end
wait(.8)
for i, part in ipairs(Parts) do
spawn(function()
script.UnionAudio["Slight Woosh"]:Play()
local Num = 12
for i = Num, 0, -1 do -- This means : Start at Num, go to 0, with a step of -1
task.wait()
part.Orientation += Vector3.new(0,25,0)
for _, Touching in workspace:GetPartsInPart(part) do
if game.Players:GetPlayerFromCharacter(Touching.Parent) then
Touching.Parent.HumanoidRootPart.AssemblyLinearVelocity = (part.CFrame.UpVector * 200) + (part.CFrame.LookVector * 200)
end
end
end
end)
end
wait()
end
Oh okay, cool beans! You can just ignore my comment. lol