Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How to make Y Axis raise and lower at random?

This is where I'm at and I kinda got tunnel vision when making the rotate model. What would be the most efficient random y axis change?

local model = script.Parent local mainPart = model.Base

--Rotation values (in degrees):

local rotX = 0.1 local rotY = 0.1 local rotZ = 0.1

local delay = 0.01 -- delay between each "Frame"

local mTable = {} local offsetTable = {}

function getListOfParts(inst) for i, v in pairs(inst:GetChildren()) do if v:isA("BasePart") then table.insert(mTable, v) else getListOfParts(v) end end end

getListOfParts(model)

for i, v in pairs(mTable) do offsetTable[i] = mainPart.CFrame:toObjectSpace(mTable[i].CFrame) end

while wait(delay) do mainPart.CFrame = mainPart.CFrame * CFrame.Angles(math.rad(rotX), math.rad(rotY), math.rad(rotZ)) for i, v in pairs(mTable) do v.CFrame = mainPart.CFrame * offsetTable[i] end end

1 comment

1

Please add code blocks to your question.

1 answer

I believe what you're looking for is the math function math.random()

You can change your rotY variable to this

local rotY = math.random(0.01,1)

The parameters for math.random is

math.random(MinimumValue,UpperValue)

Also T0XN is correct, please use code blocks next time you make a post, to use codeblocks highlight your code, and press the blue Lua button

This discussion is preserved as it was. New answers, comments, and votes are closed.