Advertisement
DiscordPastebins

inf jump toggle mobile only

Nov 17th, 2024
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.49 KB | None | 0 0
  1. -- Gui to Lua
  2. -- Version: 3.6
  3.  
  4. -- Instances:
  5.  
  6. local TouchGui = Instance.new("ScreenGui")
  7. local TouchControlFrame = Instance.new("Frame")
  8. local JumpButton = Instance.new("ImageButton")
  9.  
  10. -- Properties:
  11.  
  12. TouchGui.Name = "TouchGui"
  13. TouchGui.Parent = game.Players.LocalPlayer:WaitForChild("PlayerGui")
  14. TouchGui.ZIndexBehavior = Enum.ZIndexBehavior.Sibling
  15. TouchGui.ResetOnSpawn = false
  16.  
  17. TouchControlFrame.Name = "TouchControlFrame"
  18. TouchControlFrame.Parent = TouchGui
  19. TouchControlFrame.BackgroundTransparency = 1.000
  20. TouchControlFrame.BorderColor3 = Color3.fromRGB(27, 42, 53)
  21. TouchControlFrame.Size = UDim2.new(1, 0, 1, 0)
  22.  
  23. JumpButton.Name = "JumpButton"
  24. JumpButton.Parent = TouchControlFrame
  25. JumpButton.BackgroundTransparency = 1.000
  26. JumpButton.BorderColor3 = Color3.fromRGB(27, 42, 53)
  27. JumpButton.Position = UDim2.new(0.900000036, -95, 1.01530623, -90)
  28. JumpButton.Size = UDim2.new(0, 60, 0, 60)
  29. JumpButton.Image = "rbxassetid://17778284226"
  30. JumpButton.ImageTransparency = 0.500
  31.  
  32. -- Scripts:
  33.  
  34. local function YJFYK_fake_script() -- JumpButton.LocalScript
  35. local script = Instance.new('LocalScript', JumpButton)
  36.  
  37. local button = script.Parent -- Reference to the ImageButton
  38. local infJumpEnabled = false -- State of infinite jump
  39. local userInputService = game:GetService("UserInputService")
  40. local player = game.Players.LocalPlayer
  41.  
  42. -- Function to update the button's image
  43. local function updateButtonImage()
  44. if infJumpEnabled then
  45. button.Image = "rbxassetid://17755361063" -- ON image asset
  46. else
  47. button.Image = "rbxassetid://17778284226" -- OFF image asset
  48. end
  49. end
  50.  
  51. -- Toggle infinite jump state
  52. local function toggleInfJump()
  53. infJumpEnabled = not infJumpEnabled
  54. updateButtonImage()
  55. end
  56.  
  57. -- Infinite jump function
  58. local function enableInfiniteJump()
  59. local character = player.Character or player.CharacterAdded:Wait()
  60. local humanoid = character:FindFirstChild("Humanoid")
  61. if humanoid then
  62. humanoid:ChangeState(Enum.HumanoidStateType.Jumping)
  63. end
  64. end
  65.  
  66. -- Listen to the mobile jump button
  67. local function setupMobileJumpButton()
  68. local touchGui = player:WaitForChild("PlayerGui"):WaitForChild("TouchGui")
  69. local jumpButton = touchGui:WaitForChild("TouchControlFrame"):WaitForChild("JumpButton")
  70.  
  71. jumpButton.MouseButton1Click:Connect(function()
  72. if infJumpEnabled then
  73. enableInfiniteJump()
  74. end
  75. end)
  76. end
  77.  
  78. -- Listen to spacebar or general inputs
  79. local function onInputBegan(input, isProcessed)
  80. if infJumpEnabled and not isProcessed then
  81. if input.KeyCode == Enum.KeyCode.Space then
  82. enableInfiniteJump()
  83. end
  84. end
  85. end
  86.  
  87. -- Initialize
  88. button.MouseButton1Click:Connect(toggleInfJump)
  89. userInputService.InputBegan:Connect(onInputBegan)
  90.  
  91. -- Set initial button image
  92. updateButtonImage()
  93.  
  94. -- Setup the mobile jump button
  95. if userInputService.TouchEnabled then
  96. setupMobileJumpButton()
  97. end
  98.  
  99. end
  100. coroutine.wrap(YJFYK_fake_script)()
  101. local function HPMNU_fake_script() -- JumpButton.MobileOnly
  102. local script = Instance.new('LocalScript', JumpButton)
  103.  
  104.  
  105. --this script is gonna make his parent visible only for mobile users
  106. script.Parent.Visible = false -- makes his parent invisible for pc players
  107.  
  108. uis = game:GetService("UserInputService") -- this line gets the service
  109. ismobile = uis.TouchEnabled -- this line checks if the user is on mobile
  110.  
  111. script.Parent.Visible = ismobile -- this line makes the script's parent visible on mobile user screen
  112. end
  113. coroutine.wrap(HPMNU_fake_script)()
  114.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement