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

What's wrong with my magnitude?

Asked by
neoG457 315 Moderation Voter
8 years ago
ID1 = "http://www.roblox.com/asset/?id=366295954"
ID2 = "http://www.roblox.com/asset/?id=366314260"

AttackList = {ID1, ID2,}

local Player = game.Players.LocalPlayer
local Mouse = Player:GetMouse()

enabled = true

Mouse.Button1Down:connect(function(key)
    if not enabled then
        return
    end

    enabled = false

local Rin_BasicAnim    = Instance.new("Animation")
Rin_BasicAnim.AnimationId = AttackList[math.random(1, 2)]
local animTrack        = Player.Character.Humanoid:LoadAnimation(Rin_BasicAnim)
animTrack:Play()

wait(1)

if Rin_BasicAnim.AnimationId == ID1 then
    for _, Target in pairs (game.workspace:GetChildren()) do    
        if Target:FindFirstChild("Humanoid") then
            if Target.Torso then    
                if (Target.Torso.Position - Player.Character.Sword.Blade.Position).magnitude <= 5 and Target ~= Player.Character then

                    Target.Humanoid:TakeDamage(5)               


                end
            end
        end 
    end 
end

wait(1)

enabled = true

end)

Every time I click, 1 of the two animations (ID1 or ID2) would be picked at random from the table called AttackList, sometimes you would receive the same animation in a row however it only seems to inflict damage the first time the mouse is click and nothing happens the second, I don't know why this happens and there are no errors in the output. Please help, I believe the problem is on line 25 to 38.

Answer this question