Ad
Log in to vote
0

when i equip the tool and press Q nothing happens, what should I do?

Asked by 8 days ago
--Varables
local Form1 = script:WaitForChild("FirstForm")
local equipped = false
local UIS = game:GetService("UserInputService")
local tool = game.StarterPack.Sword


--Animate
tool.Equipped:Connect(function()
    equipped = true
end)

tool.Unequipped:Connect(function()
    equipped = false
end)

UIS.InputBegan:Connect(function(Input, isChatting)
    if isChatting then return end
    if Input.KeyCode == Enum.KeyCode.Q and equipped == true then

        local Humanoid = tool.Parent:WaitForChild("Humanoid")
        local AnimTrack = Humanoid:LoadAnimation(Form1)

        AnimTrack:Play()
    end
end)

1 answer

Log in to vote
0
Answered by
bdam3000 110
8 days ago
Edited 8 days ago

You defined tool as the sword in StarterPack. Instead, define tool as the sword the player is holding.

Change line 5 to this assuming that the script is parented to the tool

local tool = script.Parent
0
uhm the script is in starter player LiamQ926 4 — 6d
Ad

Answer this question