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

How to move a clone of a part with vector3 or CFrame?

Asked by 4 years ago

Hi, I recently made this script but it doesn't seem to work. I'm new to developing.

Here's the script:

1local clone = game.Workspace.Particle:Clone()
2 
3while true do
4    wait(0.3)
5    game.Workspace.Particle:Clone()
6    clone.Position = clone.Position + Vector3.new(0,0.1,0)
7end

I need the part (Particle) to clone itself, then move it forwards. Am currently using Vector3 but im not satisfied by its movement so if you have CFrame recommendations Im all ears!

2 answers

Log in to vote
0
Answered by 4 years ago

The answer depends on what you want. If you just want to change the position, then Vector3 should work fine. If you want to actually move the part step by step, I would recommend looking into either tweens or CFrame:Lerp().
Now, if you want to move it forward relative to the part(the way its facing) then i have no clue how to do that. Sorry i cant help on that one.

Ad
Log in to vote
0
Answered by
imKirda 4491 Moderation Voter Community Moderator
4 years ago

That's because Clone returns cloned Instance but the Instance it returns is always parented to nil so you need to parent the clone to the workspace or wherever you want, also line 5 makes no sense for you, i can't explain why, i just don't know why do you have it there.

1local clone = game.Workspace.Particle:Clone()
2clone.Parent = workspace -- for example workspace
3 
4while true do
5    wait(0.3)
6 
7    clone.Position += Vector3.new(0,0.1,0)
8end

I used += which roblox added only in 2019 i think and i don't know why only then, it basically saves you a lot of time, that way you don't need to rewrite the first value, like example:

01local Number = 50
02local String = 'hello'
03 
04Number += 50
05-- same as
06Number = Number + 50
07 
08-- or also
09Number /= 50
10Number *= 50
11Number ^= 50
12 
13-- with strings too!
14 
15String ..= ' kirda'
16 
17print(String) -- hello kirda

Answer this question