Code:
local plr = game.Players.LocalPlayer
local Targets = script.Parent.Targets
local BaseFrame = script.Parent.BaseFrame
local ProfileDisplays = BaseFrame.TopFrame.ProfileDisplays
local PlrLongestSession = plr.leaderstats.LongestSession
local function formatTime(seconds)
local hours = math.floor(seconds / 3600)
seconds = seconds % 3600
local minutes = math.floor(seconds / 60)
seconds = seconds % 60
return string.format("%02d:%02d:%02d", hours, minutes, seconds)
end
local function SetTargetPos()
local RandomX = Random.new():NextNumber(0.025,0.975)
local RandomY = Random.new():NextNumber(0.058,0.942)
print(RandomX)
print(RandomY)
return UDim2.new(RandomX,0,RandomY,0)
end
PlrLongestSession:GetPropertyChangedSignal("Value"):Connect(function()
ProfileDisplays.LongestSessionDisplay.Text = "⏱" .. formatTime(PlrLongestSession.Value)
end)
local CurrentStreak = 0
local CurrentDifficulty = 0
local AvailableTargets = {
"Square";
"Circle";
"Triangle";
};
local GameAreaFrame = BaseFrame.GameAreaFrame
local DifficultyDisplay = GameAreaFrame.DifficultyDisplay
local ChosenTarget = Targets:GetChildren()[math.random(1,#Targets:GetChildren())]
ChosenTarget.Parent = GameAreaFrame
ChosenTarget.Visible = true
local DifficultyData = require(game:GetService("ReplicatedStorage").DifficultyData)
local WaitInterval = nil
local TimeLeft = false -- time left to click target
local TS = game:GetService("TweenService")
local TweenStyle = TweenInfo.new(0.1,Enum.EasingStyle.Sine,Enum.EasingDirection.InOut)
ChosenTarget.MouseButton1Click:Connect(function()
if TimeLeft then
local Tween = TS:Create(ChosenTarget,TweenStyle,{Size = UDim2.new(0,0,0,0)})
Tween:Play()
Tween.Completed:Wait()
TimeLeft = false
end
end)
while true do
for Difficulty,Data in pairs(DifficultyData) do
if WaitInterval ~= Data.TimeInterval then WaitInterval = Data.TimeInterval end
if math.clamp(CurrentStreak,Data.MinStreak,Data.MaxStreak) == CurrentStreak and DifficultyDisplay.Text ~= Difficulty then
DifficultyDisplay.Text = Difficulty
DifficultyDisplay.TextColor3 = Data.DifficultyColor
ChosenTarget.ImageColor3 = Data.DifficultyColor
end
end
local ChosenTargetPos = SetTargetPos()
ChosenTarget.Position = ChosenTargetPos
print(ChosenTarget.Position)
TimeLeft = true
for secs = WaitInterval,0 do
if TimeLeft then
ChosenTarget.DespawnTimer.Text = tostring(math.floor(secs * 100 + 0.5) / 100)
else
break
end
task.wait(0.01)
end
TimeLeft = false
local Tween = TS:Create(ChosenTarget,TweenStyle,{Size = UDim2.new(0,0,0,0)})
Tween:Play()
Tween.Completed:Wait()
end