local RunService = game:GetService("RunService") local RS = game:GetService("ReplicatedStorage") local cfg = require(game.ReplicatedStorage.Config.Planning.Config).ChristmasArmWrestlConfig local ArmData = require(game.Players.LocalPlayer.PlayerGui.Main.Func.Armwrestling.Armwrestling.ArmData) local ArmGame = require(game.Players.LocalPlayer.PlayerGui.Main.Func.Armwrestling.Armwrestling.ArmGameClientLogic) local cachedMinPos, cachedMaxPos = 0, 0 local cachedCenter = 0 local cachedEps = 0.01 local lastLevel = -1 local lastRoundState = "" local armGameWS = workspace:WaitForChild("ArmGame") local function updateCache() local level = ArmData.curLevel.Value if level ~= lastLevel then local spawnPos = ArmData.spawnPos.Value if level < 6 then local blockSize = cfg.blockSize local v27 = (6 - level) * 2 - 1 local centerIdx = math.floor((v27 + 1) / 2) local centerPos = spawnPos - (v27 - centerIdx) * blockSize cachedMinPos = centerPos - blockSize / 2 cachedMaxPos = centerPos + blockSize / 2 else cachedMinPos = spawnPos - 0.05 cachedMaxPos = spawnPos + 0.05 end cachedCenter = (cachedMinPos + cachedMaxPos) / 2 local speed = cfg.Speed[level] or cfg.Speed[#cfg.Speed] cachedEps = math.clamp(0.001 + (0.02 - speed * 0.002), 0.002, 0.015) lastLevel = level end end RunService.Heartbeat:Connect(function() if ArmData.roundState.Value ~= "Game" or ArmData.roundInputed.Value then lastRoundState = ArmData.roundState.Value return end updateCache() local t = ArmData.judgmentlineX.Value if math.abs(t - cachedCenter) <= cachedEps then ArmGame.OnInput() end end)