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

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

Asked by 2 years 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 125
2 years ago
Edited 2 years 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 7 — 2y
Ad

Answer this question