How to use Vector3?

so I’m making a enchanted forest, and I added fireflies and I was hoping I could use vector3 to make them bob up and down lightly and maybe spin in a circle slowly. I’m not 100% sure if I use vector3 or something else. Please help.

1 Like

It would probably better to use TweenService in your case, it’s a little easier to get the effects you mentioned using it. There are also plenty of resources on it

4 Likes

You can. math.sin would most likely be your best friend, alongside math.cos if you want a bobbing and circle motion. Another way you could do the bobbing is like how Jay mentioned, which is using TweenService. Vector3 would most definitely work.

2 Likes

ok, but the thing is I know nothing on scripting, I can do like the real real basic stuff like change a brick colour, so I have no idea what to do with those.

Then you should search up some tutorials or look on the ROBLOX wiki. It’s very helpful to look in those places.

2 Likes

You can make a bobbing effect using TweenService. A quick and easy one would be like this.

local TweenService = game:GetService("TweenService")
local HEIGHT = 5
local TIME = 1
local Direction = 1
while true do
    Direction = Direction == 1 and 0 or 1
    local Tween = TweenService:Create(part, TweenInfo.new(1), {CFrame = part.CFrame * CFrame.new(0, (Direction == 1 and HEIGHT or -HEIGHT), 0)})
    Tween:Play()
    Tween.Completed:Wait()
end

This should work.

2 Likes

it says line 7 is wrong, and since I have no idea what I’m doing I don’t know how to fix it.

1 Like

Oops. Made a typo. I wrote “CFame” instead of “CFrame”.

Edit: There was also another typo. Everything should be fixed. I edited my last post so you can try copy and pasting the code to see if everything works fine now.

1 Like

still says something about expecting a bracket or something

1 Like

Yep. Like I said. Look at the post above. I fixed the code.

1 Like

I did. I fixed the typo, but its still not working

1 Like

Did you fix the bracket? (30 chars)

yes now its complaining about a nil value

edit: I think I know why, let me check

its saying part is a nil value

You have to replace “part” with what ever your using.

that’s what I thought was wrong but It still didn’t work, the part I wanted to use was called fireflys1, though that’s a model so would that still work?

this is why i dont do scripting :neutral_face:

If its a model then it won’t work as easily with a part. Your going to have to tween the PrimaryPart. Everything else in the model should be welded to the PrimaryPart.

This works fine with a part:

k ill try, just beware ill probably stuff it up

1 Like

Omg what’s this line!!! Can you explain me what this line do?

ok new problem, how do I weld? im sorry if im being a pain I only started recently