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:32 -- Luau version 6, Types version 3 -- Time taken: 0.000949 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 Luau script with better variable names and added comments -- States that disable jumping local nonJumpingStates = {"Landed", "Climbing", "Swimming", "Seated"} -- Get the parent of the script local parentObject = script.Parent -- Find and store the Humanoid object local humanoid = parentObject:WaitForChild("Humanoid") -- Enable the Jumping state initially humanoid:SetStateEnabled(Enum.HumanoidStateType.Jumping, true) -- Variable to track if jumping is temporarily disabled local isJumpingDisabled = false -- Store the initial system clock time local initialClockTime = os.clock() -- Variable to manage cooldown or delay local jumpCooldown = 0 -- Find and store the Blocking object local blockingFlag = parentObject:WaitForChild("Blocking") -- Connect a function to the StateChanged event humanoid.StateChanged:Connect(function(_, newState) -- Check if the state changed to Jumping if newState == Enum.HumanoidStateType.Jumping then -- Temporarily disable the Jumping state humanoid:SetStateEnabled(Enum.HumanoidStateType.Jumping, false) -- Set flag to indicate jumping is disabled isJumpingDisabled = true -- Update cooldown based on elapsed time jumpCooldown = math.max(jumpCooldown + 0.1 - math.max(0, (os.clock() - initialClockTime) / 1.5 - 0.4), 0) elseif isJumpingDisabled then -- Loop through the non-jumping states for _, state in nonJumpingStates do if newState == Enum.HumanoidStateType[state] then -- Update the clock time initialClockTime = os.clock() -- Calculate delay local delay = math.min(jumpCooldown, 0.4) -- Wait for the calculated delay task.wait(delay) -- If blocking is active, wait again if blockingFlag.Value then task.wait(delay) end -- Re-enable the Jumping state humanoid:SetStateEnabled(Enum.HumanoidStateType.Jumping, true) -- Reset the jumping disabled flag isJumpingDisabled = false return end end end end)