Roblox Central

Discussion for all things Roblox. (roblox.com)

Welcome to the new forum! Any suggestions you have are greatly appreciated.
WARNING: Before referring anyone to this website, Please read this topic

    Elevator Scripting

    Share

    Jfeather
    Admin

    Posts : 232
    Join date : 2009-06-18
    Location : This Forum. Duh.

    Elevator Scripting

    Post by Jfeather on Sun Aug 30, 2009 8:05 pm

    Code:
    b = script.Parent

    floor = script.Floor
    floor.Value = 0

    pos0 = b.Position
    pos1 = game.Workspace.Brick1.Position
    pos2 = game.Workspace.Brick2.Position

    Table = {pos0,pos1,pos2}



    while true do
    wait()
    projectposition = Table[floor.Value + 1]
    if projectposition == b.Position then
    --b.BodyVelocity.velocity = Vector3.new(0,0,0)
    script.dir.Value = 0
    end
    if script.dir.Value == 0 then
    b.BodyVelocity.velocity = Vector3.new(0,0,0)


    elseif script.dir.Value == 1 then
    b.BodyVelocity.velocity = Vector3.new(0,10,0)

    elseif script.dir.Value == 2 then
    b.BodyVelocity.velocity = Vector3.new(0,-10,0)
    end
    end


    Is there anything theoretically wrong with this script? Please note dir and Floor are NumValues inside this script, and methods to change these are not included.


    _________________


    Remember to link your RC profile to your Roblox profile. You can do this in the "Information" section of your profile.
    To find someone's Roblox profile, it is located under their "Contact" tab on their RC profile.
    avatar
    Earth
    Admin

    Posts : 402
    Join date : 2009-06-18
    Location : According to my IP address: Topeka, Kansas.

    Re: Elevator Scripting

    Post by Earth on Mon Aug 31, 2009 1:25 pm

    I'd use a bodyposition or CFrame you down instead of velocity.


    Also this...

    projectposition = Table[floor.Value + 1]

    Not sure what your doing here...


    Comments are your friends.

    Jfeather
    Admin

    Posts : 232
    Join date : 2009-06-18
    Location : This Forum. Duh.

    Re: Elevator Scripting

    Post by Jfeather on Mon Aug 31, 2009 7:08 pm

    Earth wrote:I'd use a bodyposition or CFrame you down instead of velocity.


    Also this...

    projectposition = Table[floor.Value + 1]

    Not sure what your doing here...


    Comments are your friends.


    I already have a working one with BodyPosition, but I wanted to make a smooth moving one instead of a suddenly moving one.

    project position is the the variable of where the brick is trying to go, for example, if floor's value is 1, then it adds one, gets 2, goes to Table[2], which is pos1. pos1 == Brick1's position, or in other words, where I want the moving brick to stop.


    Kind of confusing, but I made it this way so you could easily add and remove floors if it actually worked...which.. it didn't.


    _________________


    Remember to link your RC profile to your Roblox profile. You can do this in the "Information" section of your profile.
    To find someone's Roblox profile, it is located under their "Contact" tab on their RC profile.
    avatar
    Earth
    Admin

    Posts : 402
    Join date : 2009-06-18
    Location : According to my IP address: Topeka, Kansas.

    Re: Elevator Scripting

    Post by Earth on Tue Sep 01, 2009 1:34 pm

    Ah. I would like to suggest CFraming. Or BodyVelocity then.
    avatar
    BlueTaslem
    Learning the Ropes
    Learning the Ropes

    Posts : 32
    Join date : 2009-09-03

    Re: Elevator Scripting

    Post by BlueTaslem on Fri Sep 04, 2009 10:40 am

    I hvae one suggestion:
    Anchor the brick, and make the first line of the script be:
    script.Parent.Anchored = false


    The BodyObjects activate before the Scriptservice does, so the positions it reads off its parent's position might be in the wrong place if your BodyPosition starts with a posiion of Vector3.new(0,50,0)

    Jfeather
    Admin

    Posts : 232
    Join date : 2009-06-18
    Location : This Forum. Duh.

    Re: Elevator Scripting

    Post by Jfeather on Sun Sep 06, 2009 7:41 pm

    BlueTaslem wrote:I hvae one suggestion:
    Anchor the brick, and make the first line of the script be:
    script.Parent.Anchored = false


    The BodyObjects activate before the Scriptservice does, so the positions it reads off its parent's position might be in the wrong place if your BodyPosition starts with a posiion of Vector3.new(0,50,0)


    Wow, never considered that- thanks. I'll try it out soon and get back to you guys.


    _________________


    Remember to link your RC profile to your Roblox profile. You can do this in the "Information" section of your profile.
    To find someone's Roblox profile, it is located under their "Contact" tab on their RC profile.

    Sponsored content

    Re: Elevator Scripting

    Post by Sponsored content


      Current date/time is Mon Nov 12, 2018 3:34 pm