code:
local parent = script.Parent:GetChildren()
for i = 1,#parent do
if parent[i]:IsA("BasePart") then
while true do
wait(0.1)
v = parent[i]
for i = 1, 5 do
wait(0.1)
v.Position = v.Position + Vector3.new(0,i/40.0)
end
for i = 4, 1, -1 do
wait(0.1)
v.Position = v.Position + Vector3.new(0,i/40.0)
end
wait(0.1)
for i = 1, 5 do
wait(0.1)
v.Position = v.Position + Vector3.new(0,i/40.0)
end
for i = 4, 1, -1 do
wait(0.1)
v.Position = v.Position + Vector3.new(0,i/40.0)
end
parent[i] = v
end
end
end
so i want it so that i get both of the baseparts, to make them both float, but it doesn’t work
Another problem is that its not going down, just goes up: example
If what you meant is, getting all BasePart(s) inside a model and binding that looped float function to it, then,
local model = script.Parent
for i,v in pairs(model:GetDescendants())do
if v:IsA'BasePart' then
bindfloat(v)
end
end
As for bindfloat(), it can be something like so,
local function bindfloat(obj)
spawn(function()
while true do
wait(0.1)
local v = obj
for i = 1, 5 do
wait(0.1)
v.Position = v.Position + Vector3.new(0,i/40.0)
end
for i = 4, 1, -1 do
wait(0.1)
v.Position = v.Position + Vector3.new(0,i/40.0)
end
wait(0.1)
for i = 1, 5 do
wait(0.1)
v.Position = v.Position + Vector3.new(0,i/40.0)
end
for i = 4, 1, -1 do
wait(0.1)
v.Position = v.Position + Vector3.new(0,i/40.0)
end
end
end)
end
Just for your information however, there are more efficient ways to make an object float, I used your code as an example since you provided us with that one
local par = script.Parent
local TS = game:GetService('TweenService')
local tinfo = TweenInfo.new(4,Enum.EasingStyle.Quad,Enum.EasingDirection.In)
local function bindfloat(obj)
local anims = {}
anims.Up = TS:Create(obj,tinfo,{Position = obj.Position + Vector3.new(0,5,0)})
anims.Down = TS:Create(obj,tinfo,{Position = obj.Position})
anims.Up.Completed:Connect(function()
wait(.2)
anims.Down:Play()
end)
anims.Down.Completed:Connect(function()
wait(.4)
anims.Up:Play()
end)
anims.Up:Play()
end
for i,v in pairs(par:GetDescendants())do
if v:IsA'BasePart' then
bindfloat(v)
end
end
You can play around with the duration and easing styles/direction to make the float up/down more fluid