so im trying to make a spindash (ability from Sonic) script and i've run into a problem where if you hold shift in the air, the first half obviously doesnt execute, but if you then release shift after you landed the second half does execute, i tried to bandage this with a "Jumped" value that should be changed to true if the player holds shift while in the air. Yet it always returns false whenever i ask it to be printed
local UIS = game:GetService("UserInputService") local Player = game.Players.LocalPlayer.Character local humanoid = Player.Humanoid local anim = Instance.new("Animation") anim.AnimationId = "http://www.roblox.com/asset/?id=4491181250" local counter = 157 --put the character's walkspeed here local OrgWS = 157 --put the character's walkspeed here local debounce = false local playAnimA = humanoid:LoadAnimation(anim) local Jumped = false UIS.InputBegan:Connect(function(inst) if not debounce then if humanoid:GetState() ~= Enum.HumanoidStateType.Freefall then if inst.KeyCode == Enum.KeyCode.LeftShift then debounce = true Player.HumanoidRootPart.Anchored = true playAnimA:Play() Player.TrailPart.Smoke.Enabled = true Player.TrailPart.Dirt.Enabled = true if inst.KeyCode == Enum.KeyCode.LeftShift then counter=counter-70 end wait(0.5) if inst.KeyCode == Enum.KeyCode.LeftShift then counter=OrgWS+10 wait(1) if inst.KeyCode == Enum.KeyCode.LeftShift then counter=counter+35 wait(3) if inst.KeyCode == Enum.KeyCode.LeftShift then counter=counter+15 else Jumped = true end end end end end end end) UIS.InputEnded:Connect(function(inst) if humanoid:GetState() ~= Enum.HumanoidStateType.Freefall then if Jumped == false then if inst.KeyCode == Enum.KeyCode.LeftShift then print("Jumped is" == Jumped) debounce = true Player.HumanoidRootPart.Anchored = false Player.TrailPart.Smoke.Enabled = false Player.TrailPart.Dirt.Enabled = false playAnimA:Play() humanoid.WalkSpeed = counter humanoid.JumpPower = humanoid.JumpPower +24 Player.TrailPart.Trail.Enabled = true wait(1) if inst.KeyCode == Enum.KeyCode.Space then humanoid.WalkSpeed = humanoid.WalkSpeed -25 humanoid.JumpPower = humanoid.JumpPower -24 playAnimA:Stop() else humanoid.WalkSpeed = humanoid.WalkSpeed -10 humanoid.JumpPower = humanoid.JumpPower -24 wait(1) humanoid.WalkSpeed = humanoid.WalkSpeed -15 wait(1) humanoid.WalkSpeed = OrgWS playAnimA:Stop() Player.TrailPart.Trail.Enabled = false counter = 157 OrgWS = 157 debounce = false end end end end end)
here's is the localscript btw.