The animations are supposed to play 4 secs apart from each mouse click but take from between 20 - 3 seconds to do. I have no idea how to fix this. Not to mention the audio does not play when damage is done.

(Note: The animations are in R6) The tutorial I am watching to do this: http://https://www.youtube.com/watch?v=vh8Ggpp_RR4

Enabled = true

script.Parent.OnServerEvent:Connect(function(Player, Action, V1)
    local c = Player.Character
    if Enabled == false then return end
	    if Action == "AS" then
		Enabled = false
        local Punch = Instance.new("Animation")
        Punch.AnimationId = "rbxassetid://5236034047"
        local Anim = c.Humanoid:LoadAnimation(Punch)
		Anim:Play()
		end
		 wait(4)
        	local Region = Region3.new(V1-Vector3.new(2,2,2),V1+Vector3.new(2,2,2))
        	local RTable = workspace:FindPartsInRegion3(Region,nil,2)
        	for i,v in pairs(RTable) do
        	if v.Parent:FindFirstChild("Humanoid")and v.Parent:FindFirstChild("Deb") == nil and v.parent ~=c then
        	local Deb = Instance.new("BoolValue",v.Parent)
        	Deb.Name = "Deb"
        	game.Debris:AddItem(Deb,0.2)
			v.Parent.Humanoid:TakeDamage(20)
			local s = Instance.new("Sound")
			s.SoundId = "rbxassetid://444667824"
			s.PlaybackSpeed = math.random(80,120)/100
			s:Play()
		    end
		wait(4)
        Enabled = true
    end
end)

9 comments

0

Can you fix the indentation? I'm not entirely sure whats what even when viewing the source.

0

This is really weird, why are you adding a BoolValue with the debris service? And you're not even using it for anything

0

Is this better?

0

I was just following a tutorial.

0

Alright, never use YouTube tutorials for learning scripting as a beginner. This is the prime example of why you shouldn't: You didn't learn anything, you still don't know the basics, and you have no idea if what is in the tutorial is even good advice.

0

I will give you links to articles where you will find everything you need in order to actually learn this stuff:

0

thanks but i still need this problem to be fixed.

0

Is this in a server script?