I want the player to be able to hold space, and when they release it, they jump higher depending on how long they held it for.
Nothing happens at all when you begin pressing space or when you release.
FYI, I’m using ContextActionService to check when the player presses space
Video:
https://gyazo.com/e004298bba8357a2ee034127a1add3ea
Code:
-- // Variables
local PlayersHolding = {}
-- // Functions
local function Jump(Humanoid)
local b = true
print("Jump")
if b then
Humanoid:ChangeState(Enum.HumanoidStateType.Jumping)
b = false
task.wait(2)
b = true
end
end
local function RemoteFired(Player, InputState)
print(Player, InputState)
if InputState == Enum.UserInputState.Begin then
table.insert(PlayersHolding, Player)
Player.Character.Humanoid.JumpPower = 0
while table.find(PlayersHolding, Player) and task.wait(0.15) do
Player.JumpPower.Value += 1
end
elseif InputState == Enum.UserInputState.End then
for i,v in pairs(PlayersHolding) do
if v == Player then
Player.Character.Humanoid.JumpPower = Player.JumpPower.Value
Jump(Player.Character.Humanoid)
table.remove(PlayersHolding, i)
Player.Character.Humanoid.JumpPower = 0
Player.JumpPower.Value = 0
break
end
end
end
end
-- // Connections
JumpRemote.OnServerEvent:Connect(RemoteFired)