I think I need to use a coroutine in this script because it is ignoring one of the tasks, i'm not experienced on it, any help?
adebounce = false
local ReplicatedStorage = game.ReplicatedStorage
local UIS = game:GetService("UserInputService")
local char = script.Parent.Parent
local keybind = Enum.KeyCode.LeftAlt
local canjump = true
UIS.InputBegan:Connect(function(input,gameprocessed)
if gameprocessed then return end
if not canjump then return end
if input.KeyCode == keybind then
canjump = false
if canjump == false then
game.ReplicatedStorage.RemoteEventUpb:FireServer() --remote event fired when leftalt is pressed
local ContextActionService = game:GetService("ContextActionService")
local FREEZE_COMMAND = "Stunned"
ContextActionService:BindActionAtPriority(FREEZE_COMMAND, function()
return Enum.ContextActionResult.Sink
end, false, Enum.ContextActionPriority.High.Value, Enum.KeyCode.C) --freezes 'c' key
local jump = Instance.new("BodyVelocity")
-- jump.MaxForce = Vector3.new(0,50,0)
wait(0.2)
jump.Velocity = Vector3.new(0,50,0) --exerts player 1000 upward
jump.Parent = char.HumanoidRootPart
wait(0.6)
jump.Velocity = Vector3.new(0,-999,0) --exerts player -999 downward
for count = 1,8 do
wait(0,1)
end
jump:Destroy() --34
wait(2) -- this wait is supposed to carry on after
ContextActionService:UnbindAction(FREEZE_COMMAND) --this is ignored all together
wait(2)
canjump = true
end
end
end)
