|
| 09 Jul 2016 04:27 PM |
Hello commuity!
I came to ask, how can I create a sliding door for my group's base. I basically want it to be a sliding door that slides when you are near it.
I'm not a good scripter, so I came to ask.
1. What is the easiest line of code to use to make it?
2. Will making my own model for the door affect it moving? (Or do I have to use a certain model for the code?)
|
|
|
| Report Abuse |
|
|
|
| 09 Jul 2016 04:36 PM |
It's easiest if you're only moving one part.
You'll want to use a while loop that stores that X, Y, and Z values of the size and position so you can decrement the variable with each iteration and reduce the size to produce a sliding effect.
Try resizing it in studio to see which value (X, Y, or Z) changes when you make it appear to slide and then code it based on which changes
I normally use six variables for this - The X Position - The Y Position - The Z Position - The X Size - The Y Size - The Z Size
Position and size do not change equally so you may want to reduce the position by less than how much you reduce the size to get a nice animation.
If you're using multiple such as a model, I recommend setting a PrimaryPart and CFrame it from the PrimaryPart's position and find a way to not mess with size at all. |
|
|
| Report Abuse |
|
|
frommage
|
  |
| Joined: 22 Apr 2014 |
| Total Posts: 100 |
|
|
| 09 Jul 2016 05:06 PM |
My suggestion is that you take a free model of a sliding door that works, test to make sure it works, then move the scripts to the same positions in explorer for the door you want to work (If it (the script) is in a model, model your new door and put the script in the model.)
You'll need to name each part to correspond with the script
If not, PM me your design model and I'll make it WORK :D |
|
|
| Report Abuse |
|
|
fret13103
|
  |
| Joined: 15 Mar 2010 |
| Total Posts: 881 |
|
|
| 09 Jul 2016 05:17 PM |
its really easy
loop through players
make a vector using the difference in positions between the door's central part and the current players position
if the magnitude of that vector is less than lets say 10 studs then use a for loop to keep moving the sliding part of the door
|
|
|
| Report Abuse |
|
|
|
| 09 Jul 2016 05:17 PM |
@Brendon It's also easy with models because all you have to move is the main part if you set one.
#code function brag() print("R$1,086") end |
|
|
| Report Abuse |
|
|
pidgey
|
  |
| Joined: 16 Jan 2008 |
| Total Posts: 2739 |
|
|
| 09 Jul 2016 05:35 PM |
use hydraulics
beep beep +1 post woohoo |
|
|
| Report Abuse |
|
|