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

My Pad Teleport won't make the pad lower down. (simple script)?

Asked by 3 years ago

I'm having trouble with my pad teleport to teleport to this other part constantly at the right height (y value) here's the script:

while true do
    script.Parent.Position = script.Parent.Parent.Give.Position.Y(2.1) -- I need it to teleport lower
    wait(0.001)
end

1 answer

Log in to vote
1
Answered by 3 years ago
Edited 3 years ago

You can add and subtract vector3 values, so we can take advantage of that to make that work.

object.Position -= Vector3.new(0, 2.1, 0) -- this will subtract
object.Position += Vector3.new(0, 2.1, 0) -- this will add

If you want it to go up you need to add, and if you want it to go down, you subtract it. If it doesn't perfectly match, just try increasing the 2.1 value or decreasing, until it perfectly matches. So here is your script implementing that:

while true do
    script.Parent.Position -= Vector3.new(0, 2.1, 0) -- subtracting makes it lower, so we are using that
    wait(0.001)
end

Edit: it was going down forever because I was subtracting it from the same part, it needs to be subtracted from script.Parent.Parent.Give.Position. Here is the fixed (probably) script:

while true do
    script.Parent.Position = script.Parent.Parent.Give.Position - Vector3.new(0, 2.1, 0)
    wait(0.001)
end

In this one we don't need to do -= as it's not subracting from itself

0
Thanks, you've shown me so much on how to code through these past few questions, thanks (: Elimonater10000 33 — 3y
0
No problem! User#32819 0 — 3y
0
Ahh wait, It's not working. Elimonater10000 33 — 3y
0
What is exactly the problem? User#32819 0 — 3y
View all comments (11 more)
0
It keeps on flying into the air, never stopping Elimonater10000 33 — 3y
0
It probably is because the wait() is too short, or "script.Parent" is also flying in the air User#32819 0 — 3y
0
I checked it but it's still going down forever Elimonater10000 33 — 3y
0
Maybe we should use an event when them give position changes the pad moves there Elimonater10000 33 — 3y
0
Let me test a script using that rq User#32819 0 — 3y
0
rq?# Elimonater10000 33 — 3y
0
rq means right quick, and I edited the script User#32819 0 — 3y
0
ok Elimonater10000 33 — 3y
0
It worked, thanks so much. I've added another question about 4 hours ago about a food that a player eats and it gives them a speed boost. If u know how to deal with tools that would be great. Elimonater10000 33 — 3y
0
Yeah, I'll look into that User#32819 0 — 3y
0
Thanks! Elimonater10000 33 — 3y
Ad

Answer this question