Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Services
- local CoreGui = game:GetService("StarterGui")
- local Players = game:GetService("Players")
- local Workspace = game:GetService("Workspace")
- local TweenService = game:GetService("TweenService")
- local UIS = game:GetService("UserInputService")
- local playerGui = Players.LocalPlayer:WaitForChild("PlayerGui")
- -- Notify the player
- pcall(function()
- CoreGui:SetCore("SendNotification", {
- Title = "Car Crushers 2",
- Text = "Speed script and core control loaded.",
- Duration = 5,
- Button1 = "OK",
- })
- end)
- -- UI Setup
- local function createUI()
- local screenGui = Instance.new("ScreenGui")
- screenGui.Name = "EnergyCoreUI"
- screenGui.ZIndexBehavior = Enum.ZIndexBehavior.Sibling
- screenGui.Parent = playerGui
- local infoFrame = Instance.new("Frame")
- infoFrame.Name = "Info"
- infoFrame.BackgroundColor3 = Color3.fromRGB(62, 62, 62)
- infoFrame.BorderSizePixel = 2
- infoFrame.Position = UDim2.new(0.475, 0, 0.63, 0)
- infoFrame.Size = UDim2.new(0, 254, 0, 145)
- infoFrame.Visible = true
- infoFrame.Parent = screenGui
- return screenGui, infoFrame
- end
- local screenGui, infoFrame = createUI()
- -- Utility Functions
- local function sendNotification(title, text, duration)
- pcall(function()
- CoreGui:SetCore("SendNotification", {
- Title = title,
- Text = text,
- Duration = duration or 5,
- })
- end)
- end
- local function updateStatusText(label, newText)
- if label and typeof(label) == "Instance" and label:IsA("TextLabel") then
- label.Text = newText
- end
- end
- local function toggleVisibility(frame, isVisible)
- if frame and frame:IsA("GuiObject") then
- frame.Visible = isVisible
- end
- end
- local function makeDraggable(frame)
- local dragging = false
- local dragStart, startPos
- frame.InputBegan:Connect(function(input)
- if input.UserInputType == Enum.UserInputType.MouseButton1 then
- dragging = true
- dragStart = input.Position
- startPos = frame.Position
- end
- end)
- frame.InputEnded:Connect(function(input)
- if input.UserInputType == Enum.UserInputType.MouseButton1 then
- dragging = false
- end
- end)
- UIS.InputChanged:Connect(function(input)
- if dragging and input.UserInputType == Enum.UserInputType.MouseMovement then
- local delta = input.Position - dragStart
- frame.Position = UDim2.new(
- startPos.X.Scale,
- startPos.X.Offset + delta.X,
- startPos.Y.Scale,
- startPos.Y.Offset + delta.Y
- )
- end
- end)
- end
- makeDraggable(infoFrame)
- -- Dynamic Energy Status Handling
- local function getEnergyStatusText(status)
- local statusTexts = {
- ["FILLING"] = "Energy Status: Filling",
- ["NOT FILLING"] = "Energy Status: Not Filling",
- ["FULL"] = "Energy Status: Full",
- }
- return statusTexts[status] or "Energy Status: Unknown"
- end
- local function updateEnergyStatus(energyLabel, energyCore)
- if energyCore and typeof(energyCore) == "Instance" then
- local status = energyCore:FindFirstChild("Status") and energyCore.Status.Value
- local newText = getEnergyStatusText(status)
- updateStatusText(energyLabel, newText)
- else
- updateStatusText(energyLabel, "Energy Core not found")
- end
- end
- -- Button Connections
- local function connectButton(button, action)
- if button and button:IsA("TextButton") then
- button.MouseButton1Click:Connect(action)
- else
- warn("Button not found or invalid")
- end
- end
- -- Energy Core Actions
- local function startEnergyCore()
- local energyCore = Workspace:FindFirstChild("EnergyCore")
- if energyCore then
- sendNotification("Energy Core", "Filling started.")
- -- Add logic to start filling the energy core
- else
- sendNotification("Error", "Energy Core not found.")
- end
- end
- -- Example Usage: Connecting Button to Action
- local exampleButton = Instance.new("TextButton")
- exampleButton.Name = "StartEnergy"
- exampleButton.Size = UDim2.new(0, 100, 0, 50)
- exampleButton.Position = UDim2.new(0.5, -50, 0.8, 0)
- exampleButton.Text = "Start Energy"
- exampleButton.Parent = infoFrame
- connectButton(exampleButton, startEnergyCore)
- -- Final Touch
- sendNotification("Energy Core Script", "UI and functionality loaded successfully.")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement