Im trying to create something where in the local side the player fires an event that handles the startup delay and manually makes the player jump after the delay
local script:
local jumpEvent = ReplicatedStorage:WaitForChild("EMovements"):WaitForChild("JumpEvent")
local UserInputService = game:GetService("UserInputService")
UserInputService.InputBegan:Connect(function(input, gameProcessed)
if gameProcessed then return end
if input.KeyCode == Enum.KeyCode.Space then
jumpEvent:FireServer()
end
end)```
---------------------------------------------------------
Server-side script:
```local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local jumpEvent = ReplicatedStorage:WaitForChild("EMovements"):WaitForChild("JumpEvent")
local jumpDelay = 1
local debounce = {}
local function disableSpacebarJump(player)
local function onCharacterAdded(character)
local humanoid = character:WaitForChild("Humanoid")
humanoid:ChangeState(Enum.HumanoidStateType.Physics)
jumpEvent.OnServerEvent:Connect(function()
if debounce[player.UserId] then return end
debounce[player.UserId] = true
wait(jumpDelay)
humanoid:ChangeState(Enum.HumanoidStateType.Jumping)
print(player.Name .. " has jumped")
debounce[player.UserId] = false
end)
end
player.CharacterAdded:Connect(onCharacterAdded)
if player.Character then
onCharacterAdded(player.Character)
end
end
Players.PlayerAdded:Connect(disableSpacebarJump)