generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripting Helpers
Home Search
 

Need help fast!

Previous Thread :: Next Thread 
TacoConsumer is not online. TacoConsumer
Joined: 24 Apr 2010
Total Posts: 1563
01 Apr 2012 03:14 AM
Hey guys, I have a door and when you click the button it goes up, and when you click it again it goes down. How can I make it so it does the opposite and stays up, and when you press it it goes down?

The script is pretty long, sorry about that.

local d = script.Parent.Door
local origin = d.CFrame.y
local b = {}
for _,v in pairs(script.Parent:GetChildren()) do if ((v.className == "Part") and (v.Name == "Button")) then table.insert(b,v) end end

local active = false
local pos = 0

function moveDoor(dir)
if (dir == 0) then
for i = d.CFrame.y,origin,-0.1 do
d.CFrame = CFrame.new(d.CFrame.x,i,d.CFrame.z)
wait()
end
d.CFrame = CFrame.new(d.CFrame.x,origin,d.CFrame.z)
else
local mth = ((d.CFrame.y+(d.Size.y/2))+(d.Size.y/2-1))
for i = origin,((d.CFrame.y+(d.Size.y/2))+(d.Size.y/2-1)),0.1 do
d.CFrame = CFrame.new(d.CFrame.x,i,d.CFrame.z)
wait()
end
d.CFrame = CFrame.new(d.CFrame.x,mth,d.CFrame.z)
end
end

function setup()
for _,v in pairs(b) do
v.Click.MouseClick:connect(function()
if (active) then return end
active = true
if (pos == 0) then
pos = 1
else
pos = 0
end
moveDoor(pos)
active = false
end)
end
end

setup()
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image