Answered by
4 years ago Edited 4 years ago
It's because crouch() is an unknown function. Scripts run from line 1 to line x. So to fix this issue. Simply have function crouch() at the top of your script
02 | if player:FindFirstChild( "Contestant" ) then |
03 | if animPlaying = = false then |
04 | local animObj = Instance.new( "Animation" ) |
05 | animObj.AnimationId = animationID |
06 | local loadedAnim = player.Character.Humanoid:LoadAnimation(animObj) |
08 | player.Character.Humanoid.WalkSpeed = 10 |
10 | script.Parent.Crouch.ImageColor 3 = Color 3. fromRGB( 26 , 144 , 255 ) |
11 | script.Parent.Crouch.TextLabel.BackgroundColor 3 = Color 3. fromRGB( 26 , 144 , 255 ) |
15 | for i , v in pairs (player.Character.Humanoid:GetPlayingAnimationTracks()) do |
18 | player.Character.Humanoid.WalkSpeed = 16 |
20 | script.Parent.Crouch.ImageColor 3 = Color 3. fromRGB( 255 , 255 , 255 ) |
21 | script.Parent.Crouch.TextLabel.BackgroundColor 3 = Color 3. fromRGB( 255 , 255 , 255 ) |
26 | script.Parent.Crouch.MouseButton 1 Click:Connect( function () |
32 | local player = game.Players.LocalPlayer |
34 | local userInputService = game:GetService( "UserInputService" ) |
38 | local animPlaying = false |
41 | userInputService.InputBegan:Connect( function (input,gpe) |
42 | if input.KeyCode = = Enum.KeyCode.LeftControl then |
48 | script.Parent.Crouch.MouseButton 1 Click:Connect( function () |
52 | game.ReplicatedStorage.ToggleCrouch.OnClientEvent:Connect( function (visibility) |
53 | print ( "ToggleCrouch picked up visibility " .. tostring (visibility)) |
54 | script.Parent.Crouch.Visible = visibility |
55 | for i , v in pairs (player.Character.Humanoid:GetPlayingAnimationTracks()) do |
58 | player.Character.Humanoid.WalkSpeed = 16 |
60 | script.Parent.Crouch.ImageColor 3 = Color 3. fromRGB( 255 , 255 , 255 ) |
61 | script.Parent.Crouch.TextLabel.BackgroundColor 3 = Color 3. fromRGB( 255 , 255 , 255 ) |