Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

i am trying to make a two attack animations that a random but it wont work how do i fix?

local plr = game.Players.LocalPlayer
local attack = false
    local mouse = plr:GetMouse()
    local char = plr.Character
script.Parent.Activated:Connect(function()

    local hum = char.Humanoid:LoadAnimation(script.Parent.Animation or script.Parent.Animationsd)
    script.Parent.Blade.Trail.Enabled = true
    hum:Play()
    attack = true
    wait(.50)
    hum:Stop()
    script.Parent.Blade.Trail.Enabled = false

    script.Parent.Blade.Touched:Connect(function(hit)

    local hum =  hit.Parent:FindFirstChild("Humanoid")
    if hum ~= nil and attack == true then
    hum.Health = 0
    attack = false
    end
end)
end)

3 comments

0

Do you have an idea as to why it may not work?

0

nope

0

Maybe ugly and unindented code is no longer working?

1 answer

✓ Accepted answer
local plr = game.Players.LocalPlayer
local attack = false
local mouse = plr:GetMouse()
local char = plr.Character
script.Parent.Activated:Connect(function()
	local animations = {"Animation","Animationsd"}
	local hum = char.Humanoid:LoadAnimation(script.Parent[animations[math.random(1,#animations)]])
	script.Parent.Blade.Trail.Enabled = true
	hum:Play()
	attack = true
	wait(.50)
	hum:Stop()
	script.Parent.Blade.Trail.Enabled = false
	script.Parent.Blade.Touched:Connect(function(hit)
		local hum =  hit.Parent:FindFirstChild("Humanoid")
		if hum ~= nil and attack == true then
			hum.Health = 0
			attack = false
		end
	end)
end)

1 comment

0

view the source, for some reason some of line 7 is cut off

This discussion is preserved as it was. New answers, comments, and votes are closed.