How to use Vector3?

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

Sure. Basically its using a conditional statement while its setting a variable. So it’s saying, make Direction equal to what ever it is. But I gave it a condition. Direction == 1 and 0. So if direction is already equal to 1. It will set it to 0. And the or statement is just saying if its 0 then its 1. So basically it makes direction = opposite of what it is.

1 Like

There’s a good guide on how to Tween Models and it should explain some welding.

1 Like

If you have a model, you need to SetPrimaryPart. Then you tween the primary part. The primary part can be this exact purple part you have above and you just make it transparent and no collisions. I use a block that has the name “P” and I just move P around and the rest of the model follows.
Parts automatically weld when they are placed against each other. If they are like overlapping with no real edges lining up, then you probably need to manually weld them.

You can get a list of all the children and chick if it isa part and then if it is, create a weld and set part 0 and part 1.

local weldMe = pathToModel;

-- welds two parts
function weld(root, part)
   local w = Instance.new("WeldConstraint");
   w.Part0 = root;
   w.Part1 = part;
   w.Parent = root;
end

-- recursively welds everything in a model
-- THE MAIN MODEL MUST HAVE A PRIMARY PART
function recursiveWeld(root, model)
   for _, c in ipairs(model:GetChildren()) do
       if ( c:IsA("BasePart") and c ~= root) then
           weld(root, c);
           c.Anchored = false;
       elseif ( c:IsA("Model") ) then
           recursiveWeld(root, c);
       end
   end
end

Not sure if this works but it looks exactly like what I remember.