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 » Scripters
Home Search
 

Re: Super Simple Lag Free Doors

Previous Thread :: Next Thread 
judess69er is not online. judess69er
Joined: 11 Oct 2009
Total Posts: 1132
24 Sep 2017 04:40 PM
so im posting this just because. yea no real reason behind it other then i figure it will be helpful

so first start off by creating a Part and naming it "Sensor" then disable CanCollide and enable Anchor then Group that part and name the group "Door"

then create a part name it "Hinge" anchor it group it duplicate it name the 1st "Door1" and the 2nd "Door2"

then build your Door frame and Doors the way you want them to look inside their respective groups it doesn't matter how complex or simple you design them just as long as all the parts for each piece is in its own group.

so you cant have a part of the frame hanging around in Door1's group or things will start acting weird.

once your finished your Model overlay the Hinges over each of your doors so they cover them completely flush with each door and then make the Hinge Transparency = 1

then do the same with the Sensor but make it poke out 1 stud further then the Doors on each side

then Create a Script in the Door Group and place this inside it

-- Code --
local dooropener = script.DoorOpener:Clone()
local deb = true

function onTouch(hit)
if not deb then return end
if not hit.Parent:findFirstChild("Humanoid") then return end
deb = false
local opener = dooropener:Clone()
opener.Disabled = false
opener.Parent = script.Parent
repeat
wait(.5)
until opener.Parent == nil
deb = true
end

script.Parent.Sensor.Touched:connect(onTouch)
-- Code --


then Create another script inside the script you just created and name it "DoorOpener"

if you want a sliding Door Paste This script inside DoorOpener

-- Code --
local Cooldown = 0.1

-- Door Speed
local Time = 2 -- Animation length in Seconds
local Frames = 20 -- The number of frames will be played in the given Time

-- 1st Door
local door1 = script.Parent.Door1
door1.PrimaryPart = door1.Hinge

-- 2nd Door
local door2 = script.Parent.Door2
door2.PrimaryPart = door2.Hinge

for i = 1, Time*Frames do
wait()
door1:SetPrimaryPartCFrame(door1.PrimaryPart.CFrame * CFrame.new(-0.5, 0, 0))
door2:SetPrimaryPartCFrame(door2.PrimaryPart.CFrame * CFrame.new(0.5, 0, 0))
end
wait(2)
for i = 1, Time*Frames do
wait(0.1)
door1:SetPrimaryPartCFrame(door1.PrimaryPart.CFrame * CFrame.new(0.5, 0, 0))
door2:SetPrimaryPartCFrame(door2.PrimaryPart.CFrame * CFrame.new(-0.5, 0, 0))
end
wait(Cooldown)
script:remove()
-- Code --

if you want a rotating door Paste This script inside DoorOpener

-- Code --
local Cooldown = 0.1

-- Door Speed
local Time = 2 -- Animation length in Seconds
local Frames = 20 -- The number of frames will be played in the given Time

-- 1st Door
local door1 = script.Parent.Door1
door1.PrimaryPart = door1.Hinge

-- 2nd Door
local door2 = script.Parent.Door2
door2.PrimaryPart = door2.Hinge

for i = 1, Time*Frames do
wait()
door1:SetPrimaryPartCFrame(door1.PrimaryPart.CFrame * CFrame.fromEulerAnglesXYZ(0, 0.1, 0))
door2:SetPrimaryPartCFrame(door2.PrimaryPart.CFrame * CFrame.fromEulerAnglesXYZ(0, -0.1, 0))
end
wait(2)
for i = 1, Time*Frames do
wait()
door1:SetPrimaryPartCFrame(door1.PrimaryPart.CFrame * CFrame.fromEulerAnglesXYZ(0, -0.1, 0))
door2:SetPrimaryPartCFrame(door2.PrimaryPart.CFrame * CFrame.fromEulerAnglesXYZ(0, 0.1, 0))
end
wait(Cooldown)
script:remove()
-- Code --

No Credit is needed i just hope this will help cut down on the tedious effort people go through when they need a simple effective Lag free door
Report Abuse
judess69er is not online. judess69er
Joined: 11 Oct 2009
Total Posts: 1132
24 Sep 2017 04:42 PM
forgot to mention that you need to place the Door1 and Door2 Groups inside of the Door Group
Report Abuse
romiah123 is not online. romiah123
Joined: 10 May 2015
Total Posts: 65
24 Sep 2017 05:34 PM
Try this!



local debounce = 5
local door = script.Parent
local open = false

door.Touched:connect(function(p)
if p.Parent:FirstFirestChild("Humanoid") then
if open == false then open = true
door.CanCollide = false
door.Transpancy = 0.7
wait(debounce)
open = false

end)
Report Abuse
judess69er is not online. judess69er
Joined: 11 Oct 2009
Total Posts: 1132
24 Sep 2017 05:42 PM
@romiah123

that removes the smooth movement of the doors tho

your script is fine if you want doors that just vanish and re-appear with no realism.

but mine adds realism to the doors without sacrificing game performance i have tested then in a specially created lagged place that barely allows my character to move but the doors still seem to work without a problem at their full FPS and they don't add to the lag when used
Report Abuse
romiah123 is not online. romiah123
Joined: 10 May 2015
Total Posts: 65
24 Sep 2017 05:47 PM
Oh, for that you have to use hinge or CFrame * CFrame.Angles
Report Abuse
TheeDeathCaster is online. TheeDeathCaster
Joined: 19 Jun 2011
Total Posts: 1191
24 Sep 2017 05:51 PM
Why would you have the scripts remove themselves..?
Report Abuse
Mister_Manakin is not online. Mister_Manakin
Joined: 16 Sep 2009
Total Posts: 1935
24 Sep 2017 05:51 PM
CFrame is more reliable than hinges if there is a chance the place could have lag.
Report Abuse
judess69er is not online. judess69er
Joined: 11 Oct 2009
Total Posts: 1132
24 Sep 2017 07:39 PM
@TheeDeathCaster

the script removes itself at the end to prevent it from hanging around enabled after its been used, its a trick to reduce lag by reducing the amount of running scripts in your game

splitting the door Animation and the OnTouch into separate scripts also removes the chance the door will mess up cause once it has been activated it waits for the Animation Script to be removed before it can be Activated again
Report Abuse
judess69er is not online. judess69er
Joined: 11 Oct 2009
Total Posts: 1132
24 Sep 2017 07:44 PM
@Mister_Manakin

uhhm you do realize that i am using Cframe but im using the hinge as a ShadowCopy of the doors constraints then im Parenting those constraints to the Group it is a Child of and moving the model from the hinge constraints

o.o'
Report Abuse
AvidGamerReborn is not online. AvidGamerReborn
Joined: 21 Feb 2017
Total Posts: 131
24 Sep 2017 07:47 PM
hey can you paste the door into a world the open the world and put the link here? i want to see the door and how it will perform before i try and make it thx.
Report Abuse
judess69er is not online. judess69er
Joined: 11 Oct 2009
Total Posts: 1132
24 Sep 2017 07:50 PM
o.o' its a 3 part door it will work with just the Sensor and Hinge's if everything is grouped up like it should be
Report Abuse
judess69er is not online. judess69er
Joined: 11 Oct 2009
Total Posts: 1132
24 Sep 2017 07:53 PM
they are both Double doors but can easily be converted to single doors. just remove the 2nd door and the 2nd door lines from the DoorOpener script
Report Abuse
AvidGamerReborn is not online. AvidGamerReborn
Joined: 21 Feb 2017
Total Posts: 131
24 Sep 2017 07:54 PM
no what i mean is i want to see how it opens. descibing it to me is like talking to a wall lol it is MUCH easyer for me to get what im gona make if i see it perform (what i mean is how the door opens and what does it take to open the door like a press of a button or click) like i said i would like to see it in game please and thank you C:
Report Abuse
judess69er is not online. judess69er
Joined: 11 Oct 2009
Total Posts: 1132
24 Sep 2017 08:00 PM
the file tree looks like this

Door(Model) <- Script(Script), Sensor(Part),Door1(Model), Door2(Model)
Door1(Model) <- Hinge(Part)
Door2(Model) <- Hinge(Part)
Script(Script) <- DoorOpener(Script)
Report Abuse
judess69er is not online. judess69er
Joined: 11 Oct 2009
Total Posts: 1132
24 Sep 2017 08:02 PM
totally forgot to mention that you need to Disable the DoorOpener Script
Report Abuse
AvidGamerReborn is not online. AvidGamerReborn
Joined: 21 Feb 2017
Total Posts: 131
24 Sep 2017 08:03 PM
that is kinda useless because it doesnt describe to me how teh door opens and what is need to do to open the door? can you just open the world and put a link here? its really MUCH faster than you explaining it to me. ;-;
Report Abuse
judess69er is not online. judess69er
Joined: 11 Oct 2009
Total Posts: 1132
24 Sep 2017 08:05 PM
@AvidGamerReborn

you can easily convert it to a OnClick but i have them by default set up to work with OnTouch
Report Abuse
judess69er is not online. judess69er
Joined: 11 Oct 2009
Total Posts: 1132
24 Sep 2017 08:11 PM
@AvidGamerReborn

honestly don't get snappy with me if you opened your eyes you would see that i posted the OnTouch Script above both of the Door scripts

why should i take the time to post a model of it if you cant be bothered to create 2 parts 3 models and 2 scripts and paste a pre-written code in em
Report Abuse
judess69er is not online. judess69er
Joined: 11 Oct 2009
Total Posts: 1132
24 Sep 2017 08:13 PM
correction 3 parts 3 models and 2 scripts and paste a pre-written code in em
Report Abuse
AvidGamerReborn is not online. AvidGamerReborn
Joined: 21 Feb 2017
Total Posts: 131
24 Sep 2017 08:13 PM
Do they swing open? or does it just go invisible. that's what i want to know. that's why i wanted to see it. you literally couldn't sacrifice 1 minute to open the world and paste the link couldn't you.... whatever just answer my question about how it opens. if it swings open, is it smooth? slow? fast? explain it to me *OR* just open the world and paste the link so that i can see!! C:
Report Abuse
judess69er is not online. judess69er
Joined: 11 Oct 2009
Total Posts: 1132
24 Sep 2017 08:23 PM
-.-' kid really read my Original Post before replying pretty much all the info is there other then the 2 things i forgot to mention

1st being that you need to Disable the DoorOpener Script
and
2nd was that you needed to disable the Hinges CanCollide
Report Abuse
FumeiSencho is not online. FumeiSencho
Joined: 07 Apr 2013
Total Posts: 452
24 Sep 2017 08:23 PM
uhm sir
you just said "lag free doors"
yet youre spamming SetPrimaryPartCFrame, a very expensive method, every renderframe, ON THE SERVER.
if you havent noticed yet, ROBLOX's servers are cancerous and hopelessly slow. they die just from running distance formula too much. therefore you're completely wrong; it's not even close to lag free. it might seem fine in a server with 5 people, but if your game has like 20-25 people, it's going to start lagging when everyones opening and closing doors all the time.


Report Abuse
judess69er is not online. judess69er
Joined: 11 Oct 2009
Total Posts: 1132
24 Sep 2017 08:32 PM
@FumeiSencho

that's why i split the Toggle and the actual running Code into 2 scripts and then remove the script once its done...

i also know how laggy SetPrimaryPartCFrame can be when used by a novice but if you didn't notice i am using a Single Part that covers the entire model to move the model so everything is moving based off the Hinges Constraints...

really people without a brain shouldn't reply....
Report Abuse
judess69er is not online. judess69er
Joined: 11 Oct 2009
Total Posts: 1132
24 Sep 2017 08:36 PM
instead of sitting here and fighting with me about this and that why don't you try the dam Code before making assumptions about it
Report Abuse
Mister_Manakin is not online. Mister_Manakin
Joined: 16 Sep 2009
Total Posts: 1935
24 Sep 2017 09:31 PM
Splitting something between two scripts doesn't make it twice as fast. The server still has to perform one instruction at a time.
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • 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