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

Easy brick script right?

Asked by 8 years ago

Okay, So i have created a script for a brick to follow me , exactly behind my torso. using this loop function : while true do wait(0.005) brick.CFrame = Body.CFrame - Body.CFrame.lookVector * 1.5 brick.CFrame = Body.CFrame - Body.CFrame.lookVector * 1.5 end

It follows me, that part works. But how would I incorporate a hovering (up and down) addition into it, so that it follows me AND has that sweet animation that I ever so desire?

0
Use another script.. fahmisack123 385 — 8y
0
Use a code block please... lightpower26 399 — 8y

1 answer

Log in to vote
0
Answered by 8 years ago

First, I see you are using a loop to set the part's position manually. This works, but not very well as it jitters. A better solution would be to use a weld, like so (assuming you are using the same variables):

Weld = Instance.new("Weld", Body)

Weld.Part0 = Body
Weld.Part1 = brick

Weld.C0 = CFrame.new(0, 0, 1.5)

To do the animation, you can use a sine wave, like so:

local Wave = 0

while true do
    Weld.C1 = CFrame.new(0, math.sin(math.rad(Wave)), 0)    

    Wave = Wave + 10 -- Increase number to increase speed.

    wait()
end

Hope this helps.

Ad

Answer this question