this is for when a player presses the jump button, their character will jump. i want a script like this but apply it to everyone in the server. can you help me please
Player = game:GetService("Players")
local myDebounce = true
function playerJump ()
if myDebounce == true then
myDebounce = false
local localPlayer = Player.LocalPlayer
local character = localPlayer.Character
local Humanoid = character:WaitForChild("Humanoid")
local oldJumpPower = Humanoid.JumpPower
Humanoid.JumpPower = 100
Humanoid:ChangeState(Enum.HumanoidStateType.Jumping)
Humanoid.JumpPower = oldJumpPower
task.wait(1)
myDebounce = true
end
end
script.Parent.MouseButton1Click:Connect(playerJump)
I would use a remote event for this. Here’s an example:
-- Server Script
local replicatedStorage = game:GetService("ReplicatedStorage")
local jumpEvent = replicatedStorage:WaitForChild("JumpEvent")
-- Connect Event
jumpEvent.OnServerEvent:Connect(function(player)
local character = player.Character
local humanoid = character.Humanoid
local oldJumpPower = humanoid.JumpPower
humanoid.JumpPower = 100
humanoid:ChangeState(Enum.HumanoidStateType.Jumping)
humanoid.JumpPower = oldJumpPower
end)
-- Local Script
local replicatedStorage = game:GetService("ReplicatedStorage")
local jumpEvent = replicatedStorage:WaitForChild("JumpEvent")
local myDebounce = true
function playerJump ()
if myDebounce == true then
myDebounce = false
jumpEvent:FireServer()
task.wait(1)
myDebounce = true
end
end
script.Parent.MouseButton1Click:Connect(playerJump)