Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How to increase a value til it reaches to the selected max ?

Asked by 6 years ago

I'm not that great to script one, but I want to know, how can I make a script where a value (Like a Color3 ; BrickColor ; CFrame) increases until it has reaches to the wanted value ?

If you know how, please make a demo for me from all 3 versions (If possible)

1 answer

Log in to vote
0
Answered by
igric 29
6 years ago

Well... there's a simple way of doing this.

-- Set a variable of any number you want to start from

local x = 0

-- Now make a loop like i did here

while x == 10 do -- Set a max value (you must have two equal symbols)
    wait(1) -- How fast it the value going to increase (in second)
    x = x + 1 -- How much is the number gonna get increased
end -- you must have end to finish the loop

Now, if you use that for CFrame, you do

-- Put this script in the part

local part = scrip.Parent
local x = part.CFrame.X -- This is the X axis
local y = part.CFrame.Y -- This is the Y axis
local z = part.CFrame.Z -- This is the Z axis

-- Now let's say you wanna move the brick 5 studs up

while y == y + 5 do
    wait(0.1)
    y = y + 0.1
    part.CFrame = CFrame.new(x, y, z)
end

This should work. If it doesn't, message me and tell me the problem...

Ad

Answer this question