|
| 15 Jun 2016 07:20 PM |
| I'm not a great scripter, but does anyone know how to make a roof move/slide to a side by clicking a button. I want to make a stadium & with a roof that can be opened and closed. If you don't know what I mean you can search it up. |
|
|
| Report Abuse |
|
|
| 15 Jun 2016 07:44 PM |
:lerp()
#code while true do end |
|
|
| Report Abuse |
|
|
| 15 Jun 2016 07:45 PM |
Something like this?
local roof = script.Parent
local startPosition = roof.Position; local rot = roof.CFrame - root.Position; local targetPosition = startPosition + Vector3.new(100, 0, 0); -- You can mess with that value. 0,0,0 will get you no movement, 100, 0, 0 is 100 studs on the x-axis, etc. local speed = 5;
local dir = 0;
local function Open() dir = 1; end local function Close() dir = -1; end
local duration = (targetPosition-startPosition).magnitude/speed local t = 0; while (true) do local dt = wait(); t = t + dir*dt/duration; -- pretty sure that's right if (t < 0) then t = 0; end if (t > 1) then t = 1; end roof.CFrame = rot + startPosition:Lerp(targetPosition, t); end
|
|
|
| Report Abuse |
|