Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Function not playing when I press Q?

Asked by 2 years ago

I feel like there's a simple solution to this, since I copied the code over from a script that already works for me, but the solution isn't coming to me.

There's nothing in the Output, and print() will successfully print anywhere except after if not IsTyping and debounce ~= true and Input.UserInputType == Enum.KeyCode.Q then

Code (local script):

local UserInputService = game:GetService("UserInputService")
local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local debounce = false
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local swordDamage = ReplicatedStorage.SwordDamageRemoteFunction
local CurrentAction = script.Parent.Parent.CurrentAction.Value

--[[local AudioPlayerModule = require(ReplicatedStorage:WaitForChild("AudioPlayer")
AudioPlayerModule.preloadaudio({

})]]

--[[
11768323667 right
11768327293 up
11768331665 left
]]


repeat wait() until character.Humanoid
local humanoid = character.Humanoid
local anim = Instance.new("Animation")
anim.Parent = humanoid
anim.AnimationId = "https://www.roblox.com/asset/?id=11768331665"
local playAnim = humanoid:LoadAnimation(anim)

UserInputService.InputBegan:Connect(function(Input , IsTyping)
    if not IsTyping and debounce ~= true and Input.UserInputType == Enum.KeyCode.Q then
        print("test")
        wait(0.1)
        swordDamage:InvokeServer(0, false, false, false)
        playAnim:Play(0, 1, 1)
        CurrentAction = "ParryLeft"
        --sound goes here
        --AudioPlayerModule.playAudio("")
        repeat wait() until UserInputService:IsKeyDown(Enum.KeyCode.Q) == false or CurrentAction ~= "ParryLeft"
        playAnim:Stop()
        swordDamage:InvokeServer(0, false, false, false)
        CurrentAction = nil
        debounce = false
    end
end)

1 answer

Log in to vote
1
Answered by 2 years ago

Found the solution, I needed to use

Input.KeyCode == Enum.KeyCode.Q

instead of

Input.UserInputType == Enum.KeyCode.Q
Ad

Answer this question