Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local player = game:GetService("Players").LocalPlayer;
- local currency = player:WaitForChild("值"):WaitForChild("货币"):WaitForChild("金币");
- local playerGui = player:WaitForChild("PlayerGui");
- local screenGui = Instance.new("ScreenGui", playerGui);
- screenGui.IgnoreGuiInset = true;
- local gpsFrame = Instance.new("Frame", screenGui);
- gpsFrame.Size = UDim2.new(0, 200, 0, 150);
- gpsFrame.Position = UDim2.new(0, 220, 1, -160);
- gpsFrame.BackgroundColor3 = Color3.new(0, 0, 0);
- gpsFrame.BorderSizePixel = 2;
- gpsFrame.BorderColor3 = Color3.new(1, 1, 1);
- local unitButton = Instance.new("TextButton", gpsFrame);
- unitButton.Size = UDim2.new(0, 180, 0, 30);
- unitButton.Position = UDim2.new(0, 10, 0, 10);
- unitButton.BackgroundColor3 = Color3.new(0, 0, 0);
- unitButton.TextColor3 = Color3.new(1, 1, 1);
- unitButton.TextScaled = true;
- unitButton.Text = "切換單位";
- unitButton.BorderSizePixel = 2;
- unitButton.BorderColor3 = Color3.new(1, 1, 1);
- local gpsLabel = Instance.new("TextLabel", gpsFrame);
- gpsLabel.Size = UDim2.new(0, 180, 0, 45);
- gpsLabel.Position = UDim2.new(0, 10, 0, 50);
- gpsLabel.BackgroundColor3 = Color3.new(0, 0, 0);
- gpsLabel.TextColor3 = Color3.new(1, 1, 1);
- gpsLabel.TextScaled = true;
- gpsLabel.TextSize = 20;
- gpsLabel.Text = "0 ";
- gpsLabel.BorderSizePixel = 2;
- gpsLabel.BorderColor3 = Color3.new(1, 1, 1);
- local closeButton = Instance.new("TextButton", gpsFrame);
- closeButton.Size = UDim2.new(0, 180, 0, 30);
- closeButton.Position = UDim2.new(0, 10, 1, -40);
- closeButton.BackgroundColor3 = Color3.new(1, 0, 0);
- closeButton.TextColor3 = Color3.new(1, 1, 1);
- closeButton.TextScaled = true;
- closeButton.Text = "關閉並停止計算";
- closeButton.BorderSizePixel = 1;
- closeButton.MouseButton1Click:Connect(function()
- running = false;
- screenGui:Destroy();
- end);
- local previousGold = currency.Value;
- local previousTime = tick();
- local running = true;
- local units = {"秒金幣","分鐘金幣","小時金幣","天金幣"};
- local currentUnitIndex = 1;
- local gpsHistory = {};
- local function calculateGPS()
- local currentGold = currency.Value;
- local currentTime = tick();
- local timeDifference = currentTime - previousTime;
- if (timeDifference == 0) then
- timeDifference = 0.1;
- end
- local gpsValue = (currentGold - previousGold) / timeDifference;
- previousGold = currentGold;
- previousTime = currentTime;
- local gpsDisplay = 0;
- local unitLabel = "";
- table.insert(gpsHistory, gpsValue);
- if (#gpsHistory > 60) then
- table.remove(gpsHistory, 1);
- end
- local avgGPS = 0;
- for _, value in ipairs(gpsHistory) do
- avgGPS = avgGPS + value;
- end
- avgGPS = avgGPS / #gpsHistory;
- if (currentUnitIndex == 1) then
- gpsDisplay = math.floor(gpsValue);
- unitLabel = string.format("%d 金幣/秒", gpsDisplay);
- elseif (currentUnitIndex == 2) then
- gpsDisplay = math.floor(avgGPS * 60);
- unitLabel = string.format("%d 金幣/分鐘", gpsDisplay);
- elseif (currentUnitIndex == 3) then
- gpsDisplay = math.floor(avgGPS * 3600);
- if (gpsDisplay >= 1000) then
- gpsDisplay = math.floor(gpsDisplay / 1000);
- unitLabel = string.format("%d (k)金幣/小時", gpsDisplay);
- else
- unitLabel = string.format("%d 金幣/小時", gpsDisplay);
- end
- elseif (currentUnitIndex == 4) then
- gpsDisplay = math.floor(avgGPS * 86400);
- if (gpsDisplay >= 1000) then
- gpsDisplay = math.floor(gpsDisplay / 1000);
- unitLabel = string.format("%d (k)金幣/天", gpsDisplay);
- else
- unitLabel = string.format("%d 金幣/天", gpsDisplay);
- end
- end
- gpsLabel.Text = unitLabel;
- end
- task.spawn(function()
- while running do
- calculateGPS();
- task.wait(1);
- end
- end);
- unitButton.MouseButton1Click:Connect(function()
- currentUnitIndex = (currentUnitIndex % #units) + 1;
- end);
- local function enableDrag(frame)
- local dragging = false;
- local dragStart, startPos;
- frame.InputBegan:Connect(function(input)
- if ((input.UserInputType == Enum.UserInputType.MouseButton1) or (input.UserInputType == Enum.UserInputType.Touch)) then
- dragging = true;
- dragStart = input.Position;
- startPos = frame.Position;
- input.Changed:Connect(function()
- if (input.UserInputState == Enum.UserInputState.End) then
- dragging = false;
- end
- end);
- end
- end);
- frame.InputChanged:Connect(function(input)
- if (dragging and ((input.UserInputType == Enum.UserInputType.MouseMovement) or (input.UserInputType == Enum.UserInputType.Touch))) 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
- enableDrag(gpsFrame);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement