Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local tweenService = game:GetService("TweenService")
- local tweenTime = 2
- local info = TweenInfo.new(tweenTime)
- local asteroidHeight = 150
- local function tweenModel(model, CF)
- local CFrameValue = Instance.new("CFrameValue")
- CFrameValue.Value = model:GetPrimaryPartCFrame()
- CFrameValue:GetPropertyChangedSignal("Value"):Connect(function()
- model:SetPrimaryPartCFrame(CFrameValue.Value)
- end)
- local tween = tweenService:Create(CFrameValue, info, {Value = CF})
- tween:Play()
- tween.Completed:Connect(function()
- CFrameValue:Destroy()
- end)
- end
- function animateAsteroid()
- local baseplatePosition = game.Workspace.Baseplate.Position
- local baseplateSize = game.Workspace.Baseplate.Size
- local randomXCframe = math.random(baseplatePosition.X - baseplateSize.X /2, baseplatePosition.X + baseplateSize.X / 2)
- local randomZCframe = math.random(baseplatePosition.Z - baseplateSize.Z /2, baseplatePosition.Z + baseplateSize.Z / 2)
- local Asteroid = script.Asteroid:Clone()
- Asteroid.Parent = game.Workspace
- Asteroid:SetPrimaryPartCFrame(CFrame.new(randomXCframe, asteroidHeight, randomZCframe))
- local xTweenTo = math.random(baseplatePosition.X - baseplateSize.X /2, baseplatePosition.X + baseplateSize.X / 2)
- local zTweenTo = math.random(baseplatePosition.Z - baseplateSize.Z /2, baseplatePosition.Z + baseplateSize.Z / 2)
- tweenModel(Asteroid, CFrame.new(xTweenTo, baseplatePosition.Y - 10, zTweenTo))
- wait(tweenTime)
- Asteroid:Destroy()
- end
- wait(1)
- animateAsteroid()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement