Disable Jump for all players on the Server

  1. What do you want to achieve? I am trying to make a GUI that will disable jump for everyone on the server.

  2. What is the issue? The issue is that when I press the button, it does nothing.

  3. What solutions have you tried so far?
    I have tried this script,

script.Parent.MouseButton1Click:Connect(function()
	if 
		game.StarterPlayer.CharacterJumpPower = 50
	then
		game.StarterPlayer.CharacterJumpPower = 0
	end
end)

and I have looked here: Humanoid | Roblox Creator Documentation

I am really in need of some help, if you can help me with this please let me know!

1 Like

The reason why it isn’t working, is cause it’s only being replicated across your side (Assuming you’re using a LocalScript)

You can use a RemoteEvent for that, in which you can send a request from the client, to the server

Insert a RemoteEvent inside ReplicatedStorage & try this?

local Event = game.ReplicatedStorage:WaitForChild("RemoteEvent")

script.Parent.MouseButton1Click:Connect(function()
	Event:FireServer()
end)
--Insert a new Server Script inside ServerScriptService

local Event = game.ReplicatedStorage:WaitForChild("RemoteEvent")

Event.OnServerEvent:Connect(function()
    if game.StarterPlayer.CharacterJumpPower == 50 then
        game.StarterPlayer.CharacterJumpPower = 0

        for _, Player in pairs(game.Players:GetPlayers()) do
           local Character = Player.Character
           if Character then
               Character.Humanoid.JumpPower = 0
           end
        end

    end
end)

Great script, thanks for the help although, I do have one slight issue it doesnt seem to disable my jump, is this an issue that will just be for studio or should I have to go into a game? image Heres my Workspace if you need it!

Oh

Change your script that detects the GuiButton to a LocalScript, and it should work just fine

You should be using a localscript in the player’s gui. So change the script parented to TextButton to a localscript instead.

I tried that and I got the same issue, sorry for late repy, I am a bit busy.

Wait I think I did a dumb mistake

Can you try this script?

--Insert a new Server Script inside ServerScriptService

local Event = game.ReplicatedStorage:WaitForChild("RemoteEvent")

Event.OnServerEvent:Connect(function()
    if game.StarterPlayer.CharacterJumpPower == 50 then
        game.StarterPlayer.CharacterJumpPower = 0

        for _, Player in pairs(game.Players:GetPlayers()) do
           local Character = Player.Character
           if Character then
               Character.Humanoid.JumpPower = 0
           end
        end

    end
end)
1 Like

That code works great! If I press the button again, I want it to enable jump for the whole server, I’ve tried it with double of everything but the disable jump script just overrides the enable jump how could I do this?

Ah, you can just reference another check then inside your OnServerEvent function :wink:

--Insert a new Server Script inside ServerScriptService

local Event = game.ReplicatedStorage:WaitForChild("RemoteEvent")

Event.OnServerEvent:Connect(function()
    if game.StarterPlayer.CharacterJumpPower == 50 then
        game.StarterPlayer.CharacterJumpPower = 0

        for _, Player in pairs(game.Players:GetPlayers()) do
           local Character = Player.Character
           if Character then
               Character.Humanoid.JumpPower = 0
           end
        end
    elseif game.StarterPlayer.CharacterJumpPower == 0 then
        game.StarterPlayer.CharacterJumpPower = 50

        for _, Player in pairs(game.Players:GetPlayers()) do
           local Character = Player.Character
           if Character then
               Character.Humanoid.JumpPower = 50
           end
        end

    end
end)
1 Like

While the jumping is disabled, I want it to show a GUI for players ranked in a certain group, and I just don’t know how to make the GUI enable jump if you press it but if you press this certain button, it will allow jumping for the person who presses that 2nd button. How could I go about this?

(I’ve got the group rank lock part done.)

Not sure what you mean, you want it to enable jump for the person pressing it?

Then you would do something like this: (in a local script, parented to the button)

If you want to only enable it for certain players, then I suggest you check out this article.

local plr = game.Players.LocalPlayer -- getting the local player

script.Parent.MouseButton1Click:Connect(function()
	-- whatever code is in here will run when the button is clicked
	if plr.Character then -- is there a character?
		if plr.Character.Humanoid.JumpPower == 50 then
			-- if they have jump enabled, then disable here
		elseif plr.Character.Humanoid.JumpPower == 0 then
			-- set jump power to 50
		end
	end
end)

Thank you, I changed it up a little to be.

local plr = game.Players.LocalPlayer 

if plr.Character.Humanoid.JumpPower == 0 then
	script.Parent.EnableM.Visible = true
end 

script.Parent.MouseButton1Click:Connect(function()
	if plr.Character.Humanoid.JumpPower == 0 then
		plr.Character.Humanoid.JumpPower = 50	
		end
	end
end)

However that doesn’t seem to work, I will need to go to bed now so I will check this again once I get back home from school. :slight_smile:

You have an extra “end” here:

Also, this part of your code

probably only runs once, as soon as you join/respawn, and unless it sets the jump power instantly, the UI will not be enabled.

To fix that (the code above), you could make it run whenever something happens. For example, you could make it run when the player’s jump power is changed using GetPropertyChangedSignal.

Example:

local plr = game.Players.LocalPlayer
plr.Character.Humanoid:GetPropertyChangedSignal("JumpPower"):Connect(function()
	-- code
end)
1 Like

Good point, I added a few things to my script so that it would check for the group and if the Jpower is 0 but the line

plr.Character.Humanoid.JumpPower == 0 then

Is red, here is the full script if you want it.

local Fram = script.Parent.EnableForM
local plr = game.Players.LocalPlayer

plr.Character.Humanoid:GetPropertyChangedSignal("JumpPower"):Connect(function()
	game.Players.PlayerAdded:Connect(function(Player)
		if Player:GetRankInGroup(2) == 200 
		plr.Character.Humanoid.JumpPower == 0 then
		Fram.Visible = true
		end
end)

script.Parent.MouseButton1Click:Connect(function()
	if plr.Character.Humanoid.JumpPower == 0 then
		plr.Character.Humanoid.JumpPower = 50	
	end
end)

Is there any solutions that could fix this issue?

I think you removed the “if” before it. Also, for

You need to change the 2 to the ID of your group.

Remember, in an “if” statement, it should look like this:

if something == true then
end

Yes, however if I remove the “if” statement, the script wont check if the player is in and ranked in the group specified, I did change the actual group ID in rblx studio so dont worry about that.

I wouldn’t recommend making a script to disable jump. Instead do this
image
Set CharacterJumpPower to 0. That should make everyone not be able to jump.
Note: Did not read the whole thing.

Its just when someone presses a select button, then they can disable jump for everyone in the game as its a transit roleplay game.

script.Parent.MouseButton1Click:Connect(function()
	
	for _, child in ipairs(game.Players:GetChildren()) do

		local character = child.Character
		local humanoid = character:FindFirstChild("Humanoid")
		
		if character and humanoid then
			
			humanoid:SetStateEnabled(Enum.HumanoidStateType.Jumping, false)
			
		end

	end
	
end)

1 Like