So, I’m trying to create a jumping beat block for an obby where when you press space or jump and it’ll activate the next block. And also you can switch them while you’re in mid air.
Here’s an example video of it working properly:
Yes, I have made one working version that “only” works on PC, not mobile. I’m trying to make it work on mobile as well but I haven’t found any solution that doesn’t require a “jank” or hacky way to do it.
This was the code that it was using:
Code
uis.InputBegan:Connect(function(inp, gameInput)
if gameInput or pointIsNearBlocks() ~= true or not (inp.KeyCode == Enum.KeyCode.Space or hum ~= nil and hum:GetState() == Enum.HumanoidStateType.Freefall) then
return
end
print("passed")
ding()
for _, p in parts do
if p.Name == tostring(beat) then
setActive(p, false)
end
end
beat += 1
if beat > maximum then
beat = 1
end
for _,v in ipairs(parts) do
if v.Name == tostring(beat) then
setActive(v, true)
end
end
end)
Here’s the video that doesn’t work properly:
In the video, That’s what happened when I tried UserInputService.JumpRequest
and Humanoid.Jumping
events. It fires way more than I’d like.
Solutions I have tried:
-
Using
UserInputService.JumpRequest
event: It fires too much, if I add a debounce to it, it’ll have a really weird timing. -
Using
Humanoid.Jumping
event: It’s just the same as JumpRequest. I’ve tried using theactive
parameter and it does work, but it won’t switch when you try clicking the jump button while in mid air, so this doesn’t do it for me. -
Using
Humanoid.StateChanged
event: Tried it and it’s basically the same asHumanoid.Jumping
. -
Using
Humanoid:GetState
function: This was my first “solution”, and tried it withinUserInputService.InputBegan
event. But I found out that it doesn’t really registerEnum.HumanoidStateType.Jumping
, most of the time it’ll register asEnum.HumanoidStateType.FreeFall
orEnum.HumanoidStateType.Running
even though you’re jumping. I did try changing the parameters to these enums but still doesn’t work. -
Using
ContextActionService:BindAction
function: This was my last resort or solution that I thought would fix it, and it did it, but for some reason it only works for one of the beat blocks, and the others doesn’t work. And yes, I’ve put anEnum.ContextActionResult.Pass
return and I have also randomized theactionName
. Also I haven’t used CAS that much so I might be missing something here.
So right now I’m kind of at a loss here. Most solutions that I tried have problems like; it fires way too much or often, using the active parameter on Humanoid.Jumping
event doesn’t work because I want it to be able to switch it when you’re in mid air aswell, thought ContextActionService:BindAction
would do it, but for some reason it’ll only register one function only even though I’ve thrown a Pass enum.
I know I could just use a TextButton
or ImageButton
to detect it but I want to know, is there any other way to detect it rather involving some hacky methods? Thank you.
(Sorry if this topic or post kind of confusing, not rly good at explaining things. And also this is my first post on scripting support, so yeah lol)