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 3 years ago

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

Here's the script:

local clone = game.Workspace.Particle:Clone()

while true do
    wait(0.3)
    game.Workspace.Particle:Clone()
    clone.Position = clone.Position + Vector3.new(0,0.1,0)
end

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 3 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
3 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.

local clone = game.Workspace.Particle:Clone()
clone.Parent = workspace -- for example workspace

while true do
    wait(0.3)

    clone.Position += Vector3.new(0,0.1,0)
end

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:

local Number = 50
local String = 'hello'

Number += 50
-- same as
Number = Number + 50

-- or also
Number /= 50
Number *= 50
Number ^= 50

-- with strings too!

String ..= ' kirda'

print(String) -- hello kirda

Answer this question