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 15:15:28 -- Luau version 6, Types version 3 -- Time taken: 0.001248 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
-- Improved version of Luau script -- Constants for different humanoid states local STATE_NAMES = {"Landed", "Climbing", "Swimming", "Seated"} local parent = script.Parent -- Get the humanoid component of the parent local humanoid = parent:WaitForChild("Humanoid") -- Enable jumping state for the humanoid humanoid:SetStateEnabled(Enum.HumanoidStateType.Jumping, true) -- Initialize variables local isJumping = false local lastJumpTime = os.clock() local jumpCooldown = 0 -- Get the blocking component of the parent local blocking = parent:WaitForChild("Blocking") -- Connect a function to humanoid's StateChanged event humanoid.StateChanged:Connect(function(previousState, newState) -- Check if the new state is Jumping if newState == Enum.HumanoidStateType.Jumping then -- Disable jumping to prevent continuous jumping humanoid:SetStateEnabled(Enum.HumanoidStateType.Jumping, false) isJumping = true -- Update jump cooldown based on time since last jump local timeDiff = os.clock() - lastJumpTime jumpCooldown = math.max(jumpCooldown + 0.1 - math.max(0, timeDiff / 1.5 - 0.4), 0) -- Otherwise, check if jumping and transition to other state elseif isJumping then for _, stateName in ipairs(STATE_NAMES) do if newState == Enum.HumanoidStateType[stateName] then lastJumpTime = os.clock() -- Calculate the minimum wait time local minimumWait = math.min(jumpCooldown, 0.4) -- Wait for the minimum time before allowing another jump task.wait(minimumWait) -- If blocking, wait for the same time again if blocking.Value then task.wait(minimumWait) end -- Re-enable jumping humanoid:SetStateEnabled(Enum.HumanoidStateType.Jumping, true) isJumping = false return end end end end)