Jump hight toggle in-game settings GUI

Hey there.
I am trying to make a jump hight toggle for my in-game settings.
No GUI needed just need help on the script.

2 Likes

I am not exactly sure what you are trying to do, but if I understand correctly, you want the player to have the default “gravity” when the setting is off, but a custom gravity when it is on.
Gravity can be change with “workspace.Gravity”, however that would change it for the entire server.

I think what you need here is to change the JumpPower of the player. This will only change the jump height, so technically not the gravity, but jumping higher should give the illusion of lower gravity.

So whenever the switch is set to off, you will want to set the jump power to the default value (which is 50), and whenever it is set to on, you will want to set the jump power to your custom value.

Also, you will want to change the jump power on the server side, else every other player would still think the player jumps very high even though the player himself jumps lower on the client (If that makes sense…).
You can set up a remote event that is fired from the client when the player switches the setting, and is received by the server where it changes the player’s jump power.
(The following script will depend on the way your switch is scripted, but you should get the idea)

--CLIENT (The script of your switch)
local remoteEvent = --define your event here
local Toggled = false
local customJumpPower = 500 --50 is the default value so this would be 10x the power
local player = game.Players.LocalPlayer

script.Parent.MouseButton1Click:Connect(function()
        if Toggled == false then
         	 Toggled = true
         	 remoteEvent:FireServer(customJumpPower)
        else
  	       Toggled = false
  	       remoteEvent:FireServer(50) --(the default jump power value)
        end
end)
--SERVER
local remoteEvent = --define your event here

remoteEvent.OnServerEvent:Connect(function(player, jumpPower)
        player.Character.Humanoid.JumpPower = jumpPower
)

Hope this helps, and please let me know in case something doesn’t work (I didn’t test the script).

I think that if you change the workspace gravity locally, it should only change that player’s gravity. I tested it in studio with two players and got this result:

Witch script am I putting where. I dont know much about scripting and GUIS I am only doing it because my scripter is on holiday for 6 more weeks

If you want the button to change only the gravity of the player not the whole game, then you can do this

Put a LocalScript inside the button

local button = script.Parent

local toggled = false

button.MouseButton1Down:Connect(function()
   if toggled == false then
      toggled = true
      game.Workspace.Gravity = -- INSERT GRAVITY NUMBER HERE, HAPPENS WHEN THE SETTING IS ON
   else
      toggled = false
      game.Workspace.Gravity = -- INSERT DEFAULT GRAVITY NUMBER, HAPPENS WHEN THE SETTING IS OFF
   end
end)

Works perfect. Have you got any idea on when you click the button it goes green like this -

1 Like

It would be easier for me if you could send the already existing script for the button please so that I wouldn’t need to make my own script lol and it would be more organized for your scripter when he does get back to it.

That is the settings GUI Script