local UIS = game:GetService("UserInputService")
local Player = game.Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local Humanoid = Character:WaitForChild("Humanoid")
local Cooldown = tick()
local JumpReqConnection
JumpReqConnection = UIS.JumpRequest:Connect(function()
print("Jump")
end)
However, once I die and try to jump the request stops working. This script is located in StarterPlayerScripts.
PS: If I test this on another game it works? I don’t know what I could have possibly done to break it. The character still jumps, just no request…
Because the character being referenced is the old character. Instances under StarterPlayerScripts gets cloned once upon the Player joining to their PlayerScripts and doesn’t reset. An easy fix would be to use StarterCharacterScripts instead, otherwise, newly reference the character and it’s children inside the connection or constantly update your top-level character/humanoid variable(s).
This isn’t the issue. Even though the character is being referenced it is not being used in the code snipped, and as I said testing this on other games works perfectly fine… I’m sure I somehow messed something up externally as this is a huge game, but I cannot figure out what I did
Is it possible for you to send (a snippet of) your code? There is another post that I found regarding failing JumpRequest and it seems to be a custom character issue: UserInputService.JumpRequest problem
Ignore the backrooms that’s not the game it’s just a spawning area, A lot of things are either broken or don’t make sense but the thing is you can jump and respawn. It prints “Jump” on jump request.
Remove the spawn location from the backrooms model btw…
I’m curious, why did you decide to use “JumpRequest” instead of checking the key they pressed? Jump request fires several times for a singular jump- so I’m wondering if theres a specific reason.
For example: this.
local UserInputService = game:GetService("UserInputService")
UserInputService.InputBegan:Connect(function(input : InputObject, gameproccessedevent : boolean)
if not gameproccessedevent and input.KeyCode == Enum.KeyCode.Space then
print("Jump!")
end
end)
You can always check if the player is alive / character exists through a simple “if” gate.
That’s fair. Though, you could also just check the humanoid’s property “jumping”, as unsuccessful jump requests still fire the function unfortunately.
My only other suggestion would be to move to using successful jumps through checking the “jump” property of the humanoid. It’s fine to handle that on the server side and only provides successful attempts.
Looks like I’m even more wrong. Using “jump” provided the same issues, just in a less-having add support for all consoles-way.
Not sure if you’ve tried something like this, where the event disconnects and reconnects each time the character dies.
local UIS = game:GetService("UserInputService")
local Player = game.Players.LocalPlayer
local Character, Humanoid
local Cooldown = tick()
local JumpReqConnection
local function CharacterAdded(newCharacter)
if Character then
Character = nil
Humanoid = nil
end
if JumpReqConnection then JumpReqConnection:Disconnect(); JumpReqConnection = nil end
Character = newCharacter
Humanoid = Character:WaitForChild("Humanoid")
JumpReqConnection = UIS.JumpRequest:Connect(function()
print("Jump")
end)
end
if Player.Character then
CharacterAdded(Player.Character)
end
Player.CharacterAdded:Connect(CharacterAdded)
Did you also try just parenting it to the workspace? Just out of curiosity to see if that works too, as if, like you said, there’s some sort of parenting bug when you respawn a player like that.