LuxurizeJoin Date: 2015-03-31 Post Count: 1289 |
So I've been trying to create a script which allows the player to charge their jump height by holding space.
It works, but the humanoid doesn't actually update the first time they release space.
If they hit space while they're in the air, the humanoid will show that the player is jumping.
(Also, sorry for the re-post; didn't think the other title was clear enough)
local PlayerService = game:GetService("Players")
local Player = PlayerService.LocalPlayer
repeat wait() until Player.Character
local Character = Player.Character
local ChargingJump = false
local MidJump = false
local Jumping = false
local Debounce = false
local JumpHeight = 0
local JumpHeightLimit = 200
local UserInputService = game:GetService("UserInputService")
local Keys = {
[Enum.KeyCode.Space] = false
}
local Anims = {
ChargingJump = "http://www.roblox.com/Asset?ID=346933059";
LandedJump = "http://www.roblox.com/Asset?ID=346941183";
}
local JumpAni = Instance.new("Animation")
JumpAni.Name = "ChargingJump"
JumpAni.AnimationId = Anims.ChargingJump
ChargingJump_Ani = Character.Humanoid:LoadAnimation(JumpAni)
local LandedAni = Instance.new("Animation")
LandedAni.Name = "LandedJump"
LandedAni.AnimationId = Anims.LandedJump
LandedJump_Ani = Character.Humanoid:LoadAnimation(LandedAni)
function ChargeJump()
local function Updater()
if Keys[Enum.KeyCode.Space] then
if Character.Humanoid.Jump then
Character.Humanoid.Jump = false
end
end
end
if Character.Humanoid.Changed:connect(Updater) then
repeat
ChargingJump_Ani:Play()
for Height = 0, JumpHeightLimit, 2 do
ChargingJump = true
wait()
print(Height)
JumpHeight = Height
if JumpHeight == JumpHeightLimit then
break
end
if Keys[Enum.KeyCode.Space] == false then
break
end
end
until Keys[Enum.KeyCode.Space] == false or JumpHeight == JumpHeightLimit
end
end
UserInputService.InputBegan:connect(function(InputObject)
if Keys[InputObject.KeyCode] == false then
if not ChargingJump and not MidJump then
Keys[InputObject.KeyCode] = true
ChargeJump()
end
end
end)
UserInputService.InputEnded:connect(function(InputObject)
if Keys[InputObject.KeyCode] then
Keys[InputObject.KeyCode] = false
ChargingJump = false
if not ChargingJump then
ChargingJump_Ani:Stop()
end
MidJump = true
print("Ayy lmao")
Character.Humanoid.Jump = true
Character.Torso.Velocity = Vector3.new(0, JumpHeight, 0)
end
end)
“Insane isn't always black or white. We're all pathological, in our own ways.” |
|
LuxurizeJoin Date: 2015-03-31 Post Count: 1289 |
Bumpity bump.
“Insane isn't always black or white. We're all pathological, in our own ways.” |
|
LuxurizeJoin Date: 2015-03-31 Post Count: 1289 |
Ugh, and another bump.
Really would like some help here.
“Insane isn't always black or white. We're all pathological, in our own ways.” |
|
|
I can explain what I did to do mine in-game if u want
i make u math.sqrt() |
|
LuxurizeJoin Date: 2015-03-31 Post Count: 1289 |
Sure, as long as I have one which works as intended as the final product.
“Insane isn't always black or white. We're all pathological, in our own ways.” |
|
|
I'm at the game where I created mine, join up and i'll explain what I did.
i make u math.sqrt() |
|
LuxurizeJoin Date: 2015-03-31 Post Count: 1289 |
Ugh, bump.
I've tried what Illegally suggested and I still can't seem to get it to work.
“Insane isn't always black or white. We're all pathological, in our own ways.” |
|
LuxurizeJoin Date: 2015-03-31 Post Count: 1289 |
And another bump.
“Insane isn't always black or white. We're all pathological, in our own ways.” |
|