This script executes a function whenever the player presses the spacebar, and then executes another whenever they release it, but there are a few problems with it.
Firstly, is there any way to make sure that it only triggers if the player isn't chatting?
Second, it's kinda glitchy... Sometimes if you release the spacebar too quickly, it holds the animation infinitely. Is there any way to fix that?
player = game.Players.LocalPlayer character = game.Players.LocalPlayer.Character humanoid = character.Humanoid local chest = game.ReplicatedStorage.Animations function onPress(inputObject, gameProcessedEvent) glideanim = humanoid:LoadAnimation(chest.Glide) if inputObject.KeyCode == Enum.KeyCode.Space then print("FLY MY SON") wait(0.3) glideanim:Play() local cape = character.Chest.Cape.Mesh cape.Scale = Vector3.new(6,-3.4,1.7) cape.Parent.GlideEffect.P = 1250 humanoid.WalkSpeed = 60 end end function OnRelease(inputObject, gameProcessedEvent) if inputObject.KeyCode == Enum.KeyCode.Space then print("FALL YOU FOOL") glideanim:Stop() local cape = character.Chest.Cape.Mesh cape.Scale = Vector3.new(1.6,-3.4,1.7) cape.Parent.GlideEffect.P = 0 humanoid.WalkSpeed = 16 end end local UserInputService = game:GetService("UserInputService") UserInputService.InputBegan:connect(onPress) UserInputService.InputEnded:connect(OnRelease)
gameProcessedEvent
means when the player is doing anything related to coreGuis, like the chat. In order to fix this, simply put a conditional statement checking to see if the gameProcessedEvent
is false.