When a user presses a certain key on the keyboard a frame will move up in a jumping motion and fall back down.
I added a cool down and a debounce
These three variables control the bounce method.
I don't know what's wrong with it, but this is my attempt at a jump event.
function Bounce(gui)
What do I need to do to fix this? Am I doing anything wrong? I checked the parents too.
local JumpHeight = 0.05
local JumpDuration = 0.5
local JumpCooldown = 1
local box = script.Parent.Box
--Jump
function keyDown(key)
if key == "z" then
local Jumpable = true
function Bounce(gui)
if not Jumpable then return end
Jumpable = false
local JumpHeight = 0.05
local JumpDuration = 0.5
local JumpCooldown = 1
box:TweenPosition(UDim2.new(gui.Position.X.Offset,gui.Position.X.Scale,gui.Position.Y.Offset,gui.Position.Y.Scale+JumpHeight),"Out","Quad",.5)
wait(JumpDuration)
box:TweenPosition(UDim2.new(gui.Position.X.Offset,gui.Position.X.Scale,gui.Position.Y.Offset,gui.Position.Y.Scale-JumpHeight),"Out","Quad",.5)
wait(JumpCooldown)
Jumpable = true
end
end
end
