ADVERTISEMENTREMOVE ADS
Game icon

milk

Milky [Beta]
2 months ago
Script preview thumbnail
Script Preview

Description

It makes a Lil gui that tweens randomly (i wasn't able to think of how to get it to be accurate)

ADVERTISEMENTREMOVE ADS
145 Lines • 4.16 KiB
Raw
local Players = game:GetService("Players")
local RunService = game:GetService("RunService")
local UserInputService = game:GetService("UserInputService")
local LocalPlayer = Players.LocalPlayer
pcall(function()
game.CoreGui:FindFirstChild("TweenTestGUI"):Destroy()
end)
local gui = Instance.new("ScreenGui", game.CoreGui)
gui.Name = "TweenTestGUI"
gui.ResetOnSpawn = false
local mainFrame = Instance.new("Frame")
mainFrame.Size = UDim2.new(0, 160, 0, 80)
mainFrame.Position = UDim2.new(0, 20, 0, 20)
mainFrame.BackgroundColor3 = Color3.fromRGB(40, 40, 40)
mainFrame.BorderSizePixel = 0
mainFrame.Active = true
mainFrame.Draggable = false -- We do it manually
mainFrame.Parent = gui
local titleBar = Instance.new("Frame")
titleBar.Size = UDim2.new(1, 0, 0, 30)
titleBar.BackgroundColor3 = Color3.fromRGB(60, 60, 60)
titleBar.BorderSizePixel = 0
titleBar.Name = "TitleBar"
titleBar.Parent = mainFrame
local titleLabel = Instance.new("TextLabel")
titleLabel.Size = UDim2.new(1, 0, 1, 0)
titleLabel.BackgroundTransparency = 1
titleLabel.Text = "TweenBot"
titleLabel.TextColor3 = Color3.new(1, 1, 1)
titleLabel.Font = Enum.Font.SourceSansBold
titleLabel.TextSize = 18
titleLabel.Parent = titleBar
local toggleButton = Instance.new("TextButton")
toggleButton.Size = UDim2.new(1, -20, 0, 30)
toggleButton.Position = UDim2.new(0, 10, 0, 40)
toggleButton.Text = "Start"
toggleButton.BackgroundColor3 = Color3.fromRGB(0, 170, 0)
toggleButton.TextColor3 = Color3.new(1, 1, 1)
toggleButton.Font = Enum.Font.SourceSansBold
toggleButton.TextSize = 20
toggleButton.Parent = mainFrame
local dragging = false
local dragInput, dragStart, startPos
titleBar.InputBegan:Connect(function(input)
if input.UserInputType == Enum.UserInputType.MouseButton1 or input.UserInputType == Enum.UserInputType.Touch then
dragging = true
dragStart = input.Position
startPos = mainFrame.Position
input.Changed:Connect(function()
if input.UserInputState == Enum.UserInputState.End then
dragging = false
end
end)
end
end)
titleBar.InputChanged:Connect(function(input)
if input.UserInputType == Enum.UserInputType.MouseMovement or input.UserInputType == Enum.UserInputType.Touch then
dragInput = input
end
end)
UserInputService.InputChanged:Connect(function(input)
if input == dragInput and dragging then
local delta = input.Position - dragStart
mainFrame.Position = UDim2.new(
startPos.X.Scale, startPos.X.Offset + delta.X,
startPos.Y.Scale, startPos.Y.Offset + delta.Y
)
end
end)
local corner1 = Vector3.new(-158, 112, -248)
local corner2 = Vector3.new(-124, 112, -188)
local minX, maxX = math.min(corner1.X, corner2.X), math.max(corner1.X, corner2.X)
local minZ, maxZ = math.min(corner1.Z, corner2.Z), math.max(corner1.Z, corner2.Z)
local fixedY = 112
local function getRandomPosition()
return Vector3.new(
math.random(minX, maxX),
fixedY,
math.random(minZ, maxZ)
)
end
local moving = false
local currentThread = nil
local function tweenToCFrame(model, targetCFrame, duration)
local startTime = tick()
local startCFrame = model:GetPivot()
while tick() - startTime < duration and moving do
local alpha = (tick() - startTime) / duration
local newCFrame = startCFrame:Lerp(targetCFrame, alpha)
model:PivotTo(newCFrame)
RunService.RenderStepped:Wait()
end
if moving then
model:PivotTo(targetCFrame)
end
end
local function startMovement()
if currentThread then return end
currentThread = task.spawn(function()
while moving and LocalPlayer.Character and LocalPlayer.Character:FindFirstChild("HumanoidRootPart") do
local char = LocalPlayer.Character
local targetPos = getRandomPosition()
local targetCFrame = CFrame.new(targetPos)
tweenToCFrame(char, targetCFrame, 0.15)
task.wait(0.1)
end
currentThread = nil
end)
end
local function toggleMovement()
moving = not moving
toggleButton.Text = moving and "Stop" or "Start"
toggleButton.BackgroundColor3 = moving and Color3.fromRGB(170, 0, 0) or Color3.fromRGB(0, 170, 0)
if moving then
startMovement()
else
currentThread = nil
end
end
toggleButton.MouseButton1Click:Connect(toggleMovement)
ADVERTISEMENTREMOVE ADS

Comments

1 comment
to add a comment
Ra

What was the dislike for:(

0
0
ADVERTISEMENTREMOVE ADS