My Toggle Jump Button is not working

  1. What do you want to achieve? Keep it simple and clear!
    I want my jump button to disable every player in the servers jump when a TextLabel is triggered.
  2. What is the issue? Include screenshots / videos if possible!

It does not disable. I am not receiving any errors but it does not work.

  1. What solutions have you tried so far? Did you look for solutions on the Developer Hub?

Yup, I cannot find some topics that is related to mine.

Server Script:

local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")

local ToggleJump = Instance.new("RemoteEvent")
ToggleJump.Name = "ToggleJumpEvent"
ToggleJump.Parent = ReplicatedStorage

ToggleJump.OnServerEvent:Connect(function(player)
    print("Received")
    local character = player.Character

    if character then
        local humanoid = character:FindFirstChildOfClass("Humanoid")

        if humanoid then
            humanoid:SetStateEnabled(Enum.HumanoidStateType.Jumping, false)
        end
    end
end)

Client Sided:

Thing["Group 54"].JumpPower.Disable.MouseButton1Click:Connect(function()
	disablejump:FireServer(plr)
end)

Thank you!

Hi, u can just set JumpPower to 0 instead SetState Humanoid

One of the issues is that the function is only referring to the Character and the Humanoid of the player who triggered the RemoteEvent, and not every player in the game. The second issue is that Humanoid:SetStateEnabled() only works on the client (as far as I’m aware), and the codeblock you posted is trying to use that from a server script.

To resolve both of these issues, the first example is a revised version of that server script using Attributes, and the second example includes code for a completely new LocalScript that every client would have (to make sure that the ability to jump is turned off for every player and not just the player who activated the RemoteEvent):

-- Revised Server Script
local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")

local ToggleJump = Instance.new("RemoteEvent")
ToggleJump.Name = "ToggleJumpEvent"
ToggleJump.Parent = ReplicatedStorage
ToggleJump:SetAttribute("EnableJump", true)

ToggleJump.OnServerEvent:Connect(function()
    local currentSetting = ToggleJump:GetAttribute("EnableJump")
    ToggleJump:SetAttribute("EnableJump", not currentSetting) -- Every time the RemoteEvent is activated, the value of the "EnableJump" Attribute is toggled (so if it's false, it'll become true, and if it's true, it'll become false). This ensures that you can enable jumping for every player by activating the RemoteEvent again.
end)

-- New LocalScript in StarterPlayerScripts
local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")

local ToggleJump = ReplicatedStorage:WaitForChild("ToggleJump")

local function GetCurrentHumanoid()
    local Character = player.Character or player.CharacterAdded:Wait()
    local Humanoid = Character:WaitForChild("Humanoid")
    if Character and Humanoid then
        return Humanoid
    end
end

local function UpdateJumpState()
    local Humanoid = GetCurrentHumanoid()
    if Humanoid then
        local currentAttributeValue = ToggleJump:GetAttribute("EnableJump")
        Humanoid:SetStateEnabled(Enum.HumanoidStateType.Jumping, currentAttributeValue)
    end
end

if player.Character then
    UpdateJumpState()
end

player.CharacterAdded:Connect(UpdateJumpState)
ToggleJump:GetAttributeChangedSignal("EnableJump"):Connect(UpdateJumpState)

And then the LocalScript you already have for firing the RemoteEvent in the first place would stay the same, unless you want to make sure that only specific players are allowed to fire the RemoteEvent, then you could make sure the revised server script checks who fired the RemoteEvent before updating the value of the Attribute.