You will be given a Luau script (that has been decompiled). You…
- User
Assistant: User: System: You will be given a Luau script (that has been decompiled). You will rename the variables and functions to sound better, make the script more coherent, and add comments to areas of the script. Return the fixed script without adding ``` as we handle that. If no script has been given, do not produce any output. Do not respond with anything but the script User: -- Decompiled with Konstant V2.1, a fast Luau decompiler made in Luau by plusgiant5 (https://discord.gg/wyButjTMhM) -- Decompiled on 2024-10-06 16:08:31 -- Luau version 6, Types version 3 -- Time taken: 0.001045 seconds
local tbl_upvr = {"Landed", "Climbing", "Swimming", "Seated"} local Parent = script.Parent local Humanoid_upvr = Parent:WaitForChild("Humanoid") Humanoid_upvr:SetStateEnabled(Enum.HumanoidStateType.Jumping, true) local var5_upvw = false local os_clock_result1_upvw = os.clock() local var7_upvw = 0 local Blocking_upvr = Parent:WaitForChild("Blocking") Humanoid_upvr.StateChanged:Connect(function(arg1, arg2) -- Line 29 --[[ Upvalues[6]: [1]: Humanoid_upvr (readonly) [2]: var5_upvw (read and write) [3]: os_clock_result1_upvw (read and write) [4]: var7_upvw (read and write) [5]: tbl_upvr (readonly) [6]: Blocking_upvr (readonly) ]] if arg2 == Enum.HumanoidStateType.Jumping then Humanoid_upvr:SetStateEnabled(Enum.HumanoidStateType.Jumping, false) var5_upvw = true var7_upvw = math.max(var7_upvw + 0.1 - math.max(0, (os.clock() - os_clock_result1_upvw) / 1.5 - 0.4), 0) elseif var5_upvw then for _, v in tbl_upvr do if arg2 == Enum.HumanoidStateType[v] then os_clock_result1_upvw = os.clock() local minimum = math.min(var7_upvw, 0.4) task.wait(minimum) if Blocking_upvr.Value then task.wait(minimum) end Humanoid_upvr:SetStateEnabled(Enum.HumanoidStateType.Jumping, true) var5_upvw = false return end end end end) Assistant: Assistant:
- Assistant
-- Renamed variables and added comments for clarity -- States which deactivate jumping local nonJumpingStates = {"Landed", "Climbing", "Swimming", "Seated"} local parent = script.Parent local humanoid = parent:WaitForChild("Humanoid") -- Enable jumping state initially humanoid:SetStateEnabled(Enum.HumanoidStateType.Jumping, true) local isJumpingDisabled = false local lastJumpDisabledTime = os.clock() local jumpCooldown = 0 local blocking = parent:WaitForChild("Blocking") humanoid.StateChanged:Connect(function(previousState, newState) --[[ Upvalues[6]: [1]: humanoid (readonly) [2]: isJumpingDisabled (read and write) [3]: lastJumpDisabledTime (read and write) [4]: jumpCooldown (read and write) [5]: nonJumpingStates (readonly) [6]: blocking (readonly) ]] -- If the humanoid starts jumping if newState == Enum.HumanoidStateType.Jumping then -- Disable jumping humanoid:SetStateEnabled(Enum.HumanoidStateType.Jumping, false) isJumpingDisabled = true -- Calculate cooldown time jumpCooldown = math.max(jumpCooldown + 0.1 - math.max(0, (os.clock() - lastJumpDisabledTime) / 1.5 - 0.4), 0) -- Handle transition from a jumping-disabled state elseif isJumpingDisabled then for _, stateName in ipairs(nonJumpingStates) do if newState == Enum.HumanoidStateType[stateName] then lastJumpDisabledTime = os.clock() -- Calculate and wait minimum cooldown local minimumCooldown = math.min(jumpCooldown, 0.4) task.wait(minimumCooldown) -- Additional wait if blocking is active if blocking.Value then task.wait(minimumCooldown) end -- Re-enable jumping humanoid:SetStateEnabled(Enum.HumanoidStateType.Jumping, true) isJumpingDisabled = false return end end end end)