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

How would I make a floating effect out of this moving script I made?

Asked by 6 years ago
Edited 6 years ago
local part=script.Parent

for i=1,50 do
    part.Position=part.Position+Vector3.new(0,0,3)
    wait(0.3)
end
0
instead of 0,0,3 you do 0,3,0 Elixcore 1337 — 6y
0
Explanation? theCJarmy7 1293 — 6y

2 answers

Log in to vote
0
Answered by 6 years ago

If you mean as if its levitating up and down then I recommend to try this (i havent tested it lol)

local part = script.Parent
while wait() do 
    for i = 1, 200 do
        wait(i/1800)
        part.Position = part.Position + Vector3.new(0,.025,0)
        if i == 100 then
            break
        end
    end
    for i = 1, 200 do
        wait(i/1800)
        part.Position = part.Position + Vector3.new(0,-.025,0)
        if i == 100 then
            break
        end
    end
end
0
why would you wait(i/1800)? and why the i==100 break thing? Why not just use for i=1,100 do? theCJarmy7 1293 — 6y
0
This works, thank you!!!! Skepticalitys 31 — 6y
Ad
Log in to vote
0
Answered by 6 years ago
Edited 6 years ago

MultipleHeadshots is wrong, you must use CFrame:

part = script.Parent
while true do 
    for i = 1, 200 do
        wait(0.1)
        part.Position.CFrame = CFrame.new(part.Position + Vector3.new(0,.2,0))
        if i == 100 then
            break
        end
    end
    for i = 1, 200 do
        wait(0.1)
        part.Position.CFrame = CFrame.new(part.Position + Vector3.new(0,-.2,0))
            break
        end
    end
end

Using CFrame + Vector3 performs the slide because the CFrame constructor is adjusting the Part's Position so that it levitates. Without CFrame the levitation would look really blocky. (And, MultipleHeadshots, just for the credit, local variables were deprecated so that the are only usable within their native code block. This happened 3 years ago when Roblox upgraded to Lua 5.1.)

0
what MultipleHeadshots 10 — 6y
0
`Vector3` works just fine. Skepticalitys 31 — 6y

Answer this question