✓ Accepted answer
I know you didn't want anyone to script it for you, but here's one way to do it. Spoilers ahead.
Put this in a local script at StarterPlayer > StarterCharacterScripts. Or put it in a server script if you have an ability that lets other players disturb the 'going uppy' ability and change "Player" to script.Parent.
local Player = game:GetService("Players").LocalPlayer
local UserInputService = game:GetService("UserInputService")
local Holding = false
local RunService = game:GetService("RunService")
local MaxTimeHolding = 2
local Debounce = false
UserInputService.InputBegan:Connect(function(key, typing)
if key.KeyCode == Enum.KeyCode.Space and typing == false and Debounce == false then
Debounce = true
Holding = true
print("Holding space")
local BodyForce = Instance.new("BodyForce")
BodyForce.Force = Vector3.new(0, 2000, 0)
BodyForce.Parent = Player.Character.Torso
local TimeHolding = 0
local Timer = RunService.Heartbeat:Connect(function(step)
if TimeHolding < MaxTimeHolding then
TimeHolding = TimeHolding + 0.04
print(TimeHolding .. " Time Holding")
else
end
end)
local Landed = Player.Character.Humanoid.StateChanged:Connect(function(state)
if state == Enum.HumanoidStateType.Landed then
Debounce = false
Holding = false
print("Landed")
end
end)
spawn(function()
while true do
wait()
if TimeHolding >= 2 or Holding == false then
Timer:Disconnect()
print("Stopped timer")
Holding = false
if BodyForce then
BodyForce:Destroy()
end
break
end
end
end)
end
end)
UserInputService.InputEnded:Connect(function(key, typing)
if key.KeyCode == Enum.KeyCode.Space and typing == false and Holding == true then
Holding = false
print("Let go of space")
end
end)
Can't yet figure out how to disconnect from Landed without breaking it. Maybe someone can comment on how to.
2 comments
you could try alignposition, shouldn't require too much math (bodymovers will be deprecated in the (near) future)
or you could use LineForce