Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

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

local part=script.Parent

for i=1,50 do
	part.Position=part.Position+Vector3.new(0,0,3)
	wait(0.3)
end

2 comments

0

instead of 0,0,3 you do 0,3,0

0

Explanation?

2 answers

✓ Accepted answer

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

2 comments

0

why would you wait(i/1800)? and why the i==100 break thing? Why not just use for i=1,100 do?

0

This works, thank you!!!!

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

2 comments

0

what

0

Vector3 works just fine.

This discussion is preserved as it was. New answers, comments, and votes are closed.