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

Why isn't my teleport script working, and is there any better methods of teleporting bricks?

Asked by 4 years ago

So I'm trying to make this game where you "fold" a piece of paper and throw it into the ceiling and the first bit of my code isn't functioning. It's just changing the position and there is probably a better way of doing this.

--dump location is 37.65, 2.626, 7.11
--base position is 50.128, 4.991, -19.182
wait(3)
script.Parent.Size = Vector3.new(0.75, 0.05, 0.35)
wait(3)
script.Parent.Position = Vector3.new(37.65, 2.626, 7.11)
game.Workspace.darts.p2.a.Position = Vector3.new(50.128, 4.991, -19.182)
game.Workspace.darts.p2.b.Position = Vector3.new(50.128, 5, -19.182)

1 answer

Log in to vote
0
Answered by 4 years ago
Edited 4 years ago

I'm not sure what the wait() functions are for as they seem purposeless for what you're trying to do, but you probably either want to use a for loop or TweenService if you're trying to get it to fluidly move into a position rather than an abrupt teleport.

Depending on the object (such as a character), it is better to use CFrame, but changing something's position or orientation will suffice in general situations.

I'm not sure exactly what you're trying to do, but I would check out the earlier links I post above if you want to do some kind of movement. The way I would rewrite the current code you have to be more efficient would be as followed:

--// SETTINGS //--

local dump_pos = Vector3.new(37.65, 2.626, 7.11);
local base_pos = Vector3.new(50.128, 4.991, -19.182);

--// VARS //--

local darts = game.Workspace:WaitForChild("darts");
local part_2 = darts:WaitForChild("p2");

local a,b = part_2:WaitForChild("a"), part_2:WaitForChild("b");

--// CHANGE POS //--

wait(3);

script.Parent.Position = dump_pos;

wait(3);

a.Position = base_pos;
b.Position = Vector3.new(base_pos.X, base_pos.Y+ 0.009, base_pos.Z);

If this wasn't what you were looking for, then I apologize, as I didn't really understand the question. I hope it helped in some way though :)

0
I was trying to make a part look like its being folded like so :https://imgur.com/a/dsv1BT4 daffynimm123 4 — 4y
Ad

Answer this question