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

Why My skills dont turn off when weapon is unequipped?

Asked by 3 years ago

you can watch this for an easier explanation. https://gyazo.com/b9fb4ca14e6a8b1ecf562f6e980fc85e

char.ChildAdded:connect(function(NewChild)
        if NewChild:IsA("Tool") then
            print("Tool added!")
            -- NewChild is the tool, do stuff for when it's equipped.
            if NewChild.Name == "Blade" then
                NewChild.Equipped:Connect(function()
                    UIS.InputBegan:Connect(function(input, IsTyping)
                        if IsTyping then
                            return
                        elseif input.UserInputType == Enum.UserInputType.MouseButton1 then ---- UserInputType for mouse. Keycode for keys 
                            if debounce == false then
                                debounce =  true 
                                currTime = tick() -- tick is real current time in game. 

                                local passedTime = currTime  - prevTime
                                if passedTime < 1 then
                                    -- Can continue the combo
                                    count = count + 1
                                    if count > 4 then
                                        count = 1
                                    end
                                else
                                    count = 1 --restart teh combo
                                end

                                Combat:FireServer("M1",count, NewChild)

                                --module.SwordCombat(count,player,NewChild)
                            end

                            prevTime = currTime
                            wait(cd)
                            debounce = false

                        elseif input.KeyCode == Enum.KeyCode.E then

                            Combat:FireServer("E",count, NewChild)



                        elseif input.KeyCode == Enum.KeyCode.R then
                            Combat:FireServer("R",count, NewChild )

                        end


                    end)
                end)
0
Because you aren't binding anything to when the tool is unequipped. You're just saying, "Every time I equip this tool, attach a listener to UIS." You're never removing the UIS listener. compUcomp 417 — 3y
0
Also, why are you only connecting tool.Equipped when the tool is added to the character? Imo it's a little redundant compUcomp 417 — 3y
0
what should I do when tool is unequipped to stop skills from working thinhs11 -2 — 3y

Answer this question