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

[Solved] Why are my tool functions not getting fired? (Activate, Deactivate, Unequipped)

Asked by
RubenKan 3615 Moderation Voter Administrator Community Moderator
7 years ago
Edited 7 years ago

This question has been solved by the original poster.

Hello,

I'm trying to make a localscript able to send functions for each gun in the players backpack, but it only prints "hello" and "hello again".

If i click, or Unequip the tool, it doesn't do anything.

function Activatez(InstanceTool,MouseDown)
    print(InstanceTool.Name, MouseDown)
end


repeat wait() until #script.Parent:GetChildren() >= #game.StarterPack:GetChildren()

for _,v in pairs(script.Parent:GetChildren()) do

    local a,b = pcall(function()

        if v:IsA("Tool") and v:FindFirstChild("IsGun") and v.IsGun.Value then

            print("Hello!") -- < that does print

            v.Activated:Connect(function()
                print("Act.")
                Activatez(v,true)
            end)

            v.Deactivated:Connect(function()
                print("Deact.")
                Activatez(v,false)
            end)

            v.Unequipped:Connect(function()
                print("Uneq.")
                Activatez(v,false)
            end)

            print("Hello, again!") -- < Also prints
        end

    end)

    if not a then warn(b) end

end
0
Ok nvm, didn't have a handle ;-; RubenKan 3615 — 7y

Answer this question