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

having problems with debounce!????

Asked by 8 years ago

Okay. so I made a sword. Once equipped on = true.

I only want the mousebutton1 event to fire when on == true. It works the first time, but if I unequip it and equip it the animation does not play at all. Any soloutions?

Player = game.Players.LocalPlayer
Tool = script.Parent
Chat = false
Damage = script.Parent.Damage.Value
RightShoulder = game.Players.LocalPlayer.Character.Torso["Right Shoulder"]
Run = game:GetService("RunService")
Mouse = Player:GetMouse()
on = false
Tool.Activated:connect(function()
    if Tool.Name == "Bronzesword" then
        Tool.Name = script.Parent.Parent.Name
            lol = script.Parent.Blade.Touched:connect(function(Hit)
            if Hit.Parent:FindFirstChild("Humanoid") ~= nil and Hit.Parent.Name ~= script.Parent.Name then
                Hit.Parent.Humanoid.Health = Hit.Parent.Humanoid.Health -Damage

            end
        end)
    end
end)
Tool.Equipped:connect(function()
    if Chat == false and on == false then
    on = true
    Chat = true
    game:GetService("Chat"):Chat(script.Parent.Parent.Head, "Time to kill some monsters!")
    end
    wait(5)
    Chat = false
end)
Tool.Unequipped:connect(function()
    on = false
end)
function Attack()
    if on == true then
        for Animation = 1, 15 do
        RightShoulder.C0 = RightShoulder.C0 *CFrame.Angles(0, 0, -0.13)
        Run.Stepped:wait()
        end
        for Animation = 1, 15 do
        RightShoulder.C0 = RightShoulder.C0 *CFrame.Angles(0, 0, 0.13)
        Run.Stepped:wait()
            end
        end
    end
Mouse.Button1Down:connect(Attack)


0
It looks like after you attack you forget to set the on to false so it can run the attack again. Xoqex 75 — 8y

Answer this question