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
 

Re: elevator help

Previous Thread :: Next Thread 
pizzasawsome is not online. pizzasawsome
Joined: 15 Dec 2008
Total Posts: 216
28 Apr 2012 07:33 AM
I have an elevator with this script:
local elevating = false
local arrived = false

function getAllParts(obj,dist)
if #obj:getChildren() > 0 then
for i, v in pairs(obj:getChildren()) do
getAllParts(v, dist)
end
end
if obj:IsA("BasePart") then
delay(0, function()
local c = obj.CFrame
if dist>0 then
obj.Velocity = Vector3.new(0,15.25,0)
for i = 0, dist, 0.3 do
obj.CFrame = c+Vector3.new(0,i,0)
game:getService("RunService").Stepped:wait()
end
else
obj.Velocity = Vector3.new(0,-15,0)
for i = 0,dist,-0.3 do
obj.CFrame = c+Vector3.new(0,i,0)
game:getService("RunService").Stepped:wait()
end
end
arrived = true
obj.Velocity = Vector3.new(0,0,0)
end)
end
end

function openDoors(door)
local opener = script.DoorOpener:Clone()
opener.Disabled = false
opener.Parent = door.Door
end

function elevate(floor)
arrived = false
elevating = true
local dist = floor.Floor.Position.y-script.Parent.Base.Position.y
print(dist)
getAllParts(script.Parent,dist)
repeat wait(1) until arrived
openDoors(script.Parent.Doors)
openDoors(floor.Doors)
delay(5,function() elevating = false end)
end

for i, v in pairs(script.Parent.Buttons:getChildren()) do
v.ClickDetector.MouseClick:connect(function()
if not elevating then
v.Reflectance = 1
local floor = script.Parent.Parent["Floor " .. v.Name]
elevate(floor)
repeat wait(1) until arrived
v.Reflectance = 0
else
v.BrickColor = BrickColor.new("Bright red")
wait(.25)
v.BrickColor = BrickColor.new("Institutional white")
end
end)
end


for i, v in pairs(script.Parent.Parent:getChildren()) do
if v.Name:sub(1,5) == "Floor" then
v.Button.ClickDetector.MouseClick:connect(function()
if not elevating then
v.Button.Reflectance = 1
local floor = v
elevate(floor)
repeat wait(1) until arrived
v.Button.Reflectance = 0
else
v.Button.BrickColor = BrickColor.new("Bright red")
wait(.25)
v.Button.BrickColor = BrickColor.new("Institutional white")
end
end)
end
end

and i have many bricks inside, and until i put these bricks in, the elevator worked fine, is there anyway i can change the script for this to work with so many parts? (the elevator does have anchored parts, but they work with the script, so i cant use another that doesn't allow anchored bricks....
Report Abuse
pizzasawsome is not online. pizzasawsome
Joined: 15 Dec 2008
Total Posts: 216
28 Apr 2012 06:44 PM
oh and it only works wrong in play mode......is there an alternative script i could use or a way to edit that one?
Report Abuse
pizzasawsome is not online. pizzasawsome
Joined: 15 Dec 2008
Total Posts: 216
30 Apr 2012 08:12 PM
someone said it was because of cframed bricks in the elevator...is that true?
Report Abuse
Boomboy45 is not online. Boomboy45
Joined: 12 Oct 2008
Total Posts: 3720
30 Apr 2012 08:56 PM
Omg.

When asking for help, don't give us 120 lines of code.
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