How can I make these functions only work if the player isn't chatting(And other similar issues)?
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?
01 | player = game.Players.LocalPlayer |
02 | character = game.Players.LocalPlayer.Character |
03 | humanoid = character.Humanoid |
04 | local chest = game.ReplicatedStorage.Animations |
05 | function onPress(inputObject, gameProcessedEvent) |
06 | glideanim = humanoid:LoadAnimation(chest.Glide) |
07 | if inputObject.KeyCode = = Enum.KeyCode.Space then |
11 | local cape = character.Chest.Cape.Mesh |
12 | cape.Scale = Vector 3. new( 6 ,- 3.4 , 1.7 ) |
13 | cape.Parent.GlideEffect.P = 1250 |
14 | humanoid.WalkSpeed = 60 |
18 | function OnRelease(inputObject, gameProcessedEvent) |
19 | if inputObject.KeyCode = = Enum.KeyCode.Space then |
20 | print ( "FALL YOU FOOL" ) |
22 | local cape = character.Chest.Cape.Mesh |
23 | cape.Scale = Vector 3. new( 1.6 ,- 3.4 , 1.7 ) |
24 | cape.Parent.GlideEffect.P = 0 |
25 | humanoid.WalkSpeed = 16 |
30 | local UserInputService = game:GetService( "UserInputService" ) |
31 | UserInputService.InputBegan:connect(onPress) |
32 | UserInputService.InputEnded:connect(OnRelease) |