Helloo. Theres an issue where my model is hovering over the ground and tweening under the floor.
Here is my script
local me = script.Parent
local positions = me.Parent.Positions:GetChildren()
local animator = script.Parent.AnimationController.Animator
local body = me["Sphere.003"]
local TS = game:GetService("TweenService")
local walktime
while true do
wait(math.random(1, 10))
--d=√((x2 – x1)² + (y2 – y1)²).
local randoposition = positions[math.random(1, #positions)]
local x1, y1 = body.Position.X, body.Position.Z
local x2, y2 = randoposition.Position.X, randoposition.Position.Z
local part1 = x2 - x1
part1 = part1 ^ 2
local part2 = y2 - y1
part2 = part2 ^ 2
local distance = math.sqrt(part1 + part2)
print(distance)
walktime = distance / 10
local Info = TweenInfo.new(
walktime,
Enum.EasingStyle.Linear
)
TS:Create(body, Info, {CFrame = randoposition.CFrame}):Play()
end
(Also if you can help me make it so the model faces the part its moving to that would be swag)