Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Why isn't this working?

Asked by
Valiux 27
8 years ago

Please make your question title relevant to your question content. It should be a one-sentence summary in question form.
function onTouched(part)
    game.Workspace.Door.DL.Vector3.new = ( 14, 0.2, 15.4 )
    wait(.1)
    game.Workspace.Door.DL.Vector3.new = ( 13.9, 0.2, 15.4 )
    wait(.1)
    game.Workspace.Door.DL.Vector3.new = ( 13.8, 0.2, 15.4 )
    wait(.1)
    game.Workspace.Door.DL.Vector3.new = ( 13.7, 0.2, 15.4 )
    wait(.1)
    game.Workspace.Door.DL.Vector3.new = ( 13.6, 0.2, 15.4 )
    wait(.1)
    game.Workspace.Door.DL.Vector3.new = ( 13.5, 0.2, 15.4 )
    wait(.1)
    game.Workspace.Door.DL.Vector3.new = ( 13.4, 0.2, 15.4 )
    wait(.1)
    game.Workspace.Door.DL.Vector3.new = ( 13.3, 0.2, 15.4 )
    wait(.1)
    game.Workspace.Door.DL.Vector3.new = ( 13.2, 0.2, 15.4 )
    wait(.1)
    game.Workspace.Door.DL.Vector3.new = ( 13.1, 0.2, 15.4 )
    wait(.1)
    game.Workspace.Door.DL.Vector3.new = ( 13, 0.2, 15.4 )
    wait(.1)
    game.Workspace.Door.DL.Vector3.new = ( 12.9, 0.2, 15.4 )
    wait(.1)
    game.Workspace.Door.DL.Vector3.new = ( 12.8, 0.2, 15.4 )
    wait(.1)
    game.Workspace.Door.DL.Vector3.new = ( 12.7, 0.2, 15.4 )
    wait(.1)
    game.Workspace.Door.DL.Vector3.new = ( 12.6, 0.2, 15.4 )
    wait(.1)
    game.Workspace.Door.DL.Vector3.new = ( 12.5, 0.2, 15.4 )
    wait(.1)
    game.Workspace.Door.DL.Vector3.new = ( 12.4, 0.2, 15.4 )
    wait(.1)
    game.Workspace.Door.DL.Vector3.new = ( 12.3, 0.2, 15.4 )
    wait(.1)
    game.Workspace.Door.DL.Vector3.new = ( 12.2, 0.2, 15.4 )
    wait(.1)
    game.Workspace.Door.DL.Vector3.new = ( 12.1, 0.2, 15.4 )
    wait(.1)
    game.Workspace.Door.DL.Vector3.new = ( 12, 0.2, 15.4 )
    wait(.1)
    game.Workspace.Door.DL.Vector3.new = ( 11.9, 0.2, 15.4 )
    wait(.1)
    game.Workspace.Door.DL.Vector3.new = ( 11.8, 0.2, 15.4 )
    wait(.1)
    game.Workspace.Door.DL.Vector3.new = ( 11.7, 0.2, 15.4 )
    wait(.1)
    game.Workspace.Door.DL.Vector3.new = ( 11.6, 0.2, 15.4 )
    wait(.1)
    game.Workspace.Door.DL.Vector3.new = ( 11.5, 0.2, 15.4 )
    wait(.1)
    game.Workspace.Door.DL.Vector3.new = ( 11.4, 0.2, 15.4 )
    wait(.1)
    game.Workspace.Door.DL.Vector3.new = ( 11.3, 0.2, 15.4 )
    wait(.1)
    game.Workspace.Door.DL.Vector3.new = ( 11.2, 0.2, 15.4 )
    wait(.1)
    game.Workspace.Door.DL.Vector3.new = ( 11.1, 0.2, 15.4 )
    wait(.1)
    game.Workspace.Door.DL.Vector3.new = ( 11, 0.2, 15.4 )
    wait(.1)
    game.Workspace.Door.DL.Vector3.new = ( 10.9, 0.2, 15.4 )
    wait(.1)
    game.Workspace.Door.DL.Vector3.new = ( 10.8, 0.2, 15.4 )
    wait(.1)
    game.Workspace.Door.DL.Vector3.new = ( 10.7, 0.2, 15.4 )
    wait(.1)
    game.Workspace.Door.DL.Vector3.new = ( 10.6, 0.2, 15.4 )
    wait(.1)
    game.Workspace.Door.DL.Vector3.new = ( 10.5, 0.2, 15.4 )
    wait(.1)
    game.Workspace.Door.DL.Vector3.new = ( 10.4, 0.2, 15.4 )
    wait(.1)
    game.Workspace.Door.DL.Vector3.new = ( 10.3, 0.2, 15.4 )
    wait(.1)
    game.Workspace.Door.DL.Vector3.new = ( 10.2, 0.2, 15.4 )
    wait(.1)
    game.Workspace.Door.DL.Vector3.new = ( 10.1, 0.2, 15.4 )
    wait(.1)
    game.Workspace.Door.DL.Vector3.new = ( 10, 0.2, 15.4 )
end
--// In the future, please put your code in a code block. All you have to do is click the blue button in edit mode, and put your code between the lines.

2 answers

Log in to vote
2
Answered by 8 years ago

You're using Vector3.new wrong.

To set a size, position, or rotation, you would use a Vector3 like so,

part.Position = Vector3.new(1,2,3)

So, that's great.

Let's shorten your code

To do this, we use a for loop. Like so,

function onTouched(part) 
    for i = 0,4,0.1 do
        game.Workspace.Door.DL.Position = Vector3.new(14-i, 0.2, 15.4)
        wait(.1)
    end
end
i goes from 0 to 4 0.1 at a time. If you didn't want position, change it to size or rotation.

Calling your function

You forgot to call you function as well.

-- Regular script in part that's in workspace
function onTouched(part) 
    for i = 0,4,0.1 do
        game.Workspace.Door.DL.Position = Vector3.new(14-i, 0.2, 15.4)
        wait(.1)
    end
end
script.Parent.Touched:connect(onTouched)
If the script isn't in the part you're calling the function on, sorry :P

Good Luck!

Ad
Log in to vote
1
Answered by 8 years ago

You have to connect the function to the Touched event, for example

script.Parent.Touched:connect(onTouched)

This is why your script isn't working.

Answer this question