What do you want to achieve? Keep it simple and clear!
I want to, using ContextActionService, bind all inputs to actions to give players the freedom to change any input to whatever button they want.
What is the issue? Include screenshots / videos if possible!
Because I’m re-binding space for jump, I need to code in my own jump. When I try setting Humanoid.Jump to true, it does nothing.
What solutions have you tried so far? Did you look for solutions on the Creator Hub?
When testing in Studio, I clicked my Humanoid’s Jump property checkbox, and it works (my character jumps). I ran a line of code in Studio’s command bar changing this property to true, and it works. I made a LocalScript that sets the property to true every 4 seconds, and it works. But when I set the Jump property to true when pressing an input, it does nothing.
Working LocalScript:
local localPlayer = game.Players.LocalPlayer
local localCharacter = localPlayer.Character or localPlayer.CharacterAdded:wait()
local localHumanoid = localCharacter:WaitForChild("Humanoid")
while wait(4) do
localHumanoid.Jump = true
end
Non-Working LocalScript:
local localPlayer = game.Players.LocalPlayer
local localCharacter = localPlayer.Character or localPlayer.CharacterAdded:wait()
local localHumanoid = localCharacter:WaitForChild("Humanoid")
game.UserInputService.InputBegan:Connect(function(input)
if input.KeyCode == Enum.KeyCode.G then -- using G just for example
localHumanoid.Jump = true
end
end)
I understand I could code my own jump system manually, but it’s discouraging running into these inconsistencies in ROBLOX’s system and having no way to figure out what’s going on. If anyone could shed some light on this, I’d appreciate it.
Then I have to run all kinds of checks to only run that code if the Humanoid:GetState() is a number of HumanoidStateTypes, or else it’ll jump even when in mid-air. But I know I can make my own jump; I’m really just trying to figure out why something so simple works sometimes but not other times.
why would you need to individually check the state types? you could probably just check if Humanoid.FloorMaterial ~= Enum.Material.Air before setting it.
considering this is the API for this, there’s likely some bonus code which runs on the C++ side rather than just setting the property, otherwise it’d be a pretty useless function. A while back I ran into this issue and using the function fixed it - it’s worth a try,
if (input.KeyCode == Enum.KeyCode.G and localHumanoid.FloorMaterial ~= Enum.Material.Air) then
localHumanoid:ChangeState(Enum.HumanoidStateType.Jumping)
end
local localPlayer = game.Players.LocalPlayer
local localCharacter = localPlayer.Character or localPlayer.CharacterAdded:wait()
local localHumanoid = localCharacter:WaitForChild("Humanoid")
game.UserInputService.InputBegan:Connect(function(input:InputObject)
if input.KeyCode == Enum.KeyCode.G and localHumanoid:GetState() ~= Enum.HumanoidStateType.Freefall then -- using G just for example
localHumanoid:ChangeState(Enum.HumanoidStateType.Jumping)
end
end)
You could also check if the humanoid’s state is not set to freefall