What do you want to achieve? I am trying to make a GUI that will disable jump for everyone on the server.
What is the issue? The issue is that when I press the button, it does nothing.
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)
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? Heres my Workspace if you need it!
--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)
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
--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)
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?
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)
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.
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)
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)
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.
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)