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

Animation from server not looping onto client?

Hey guys figured I would check in. Im still having a strange issue where events are still being run on the animationevent for the zombie but the client is unable to see it after the first time? Any advice?

Long story short. I have a basic script taken from player and put into a zombie npc. I added a animation called hand slap and in that animation there is an "End" event, as well as a "DealDamage" event.

Whats confusing is the zombie is running the animation and dealing the damage constantly but it is dealing more than 1 damage on one swing (running the GetMarkerReachedSignal method too many times, and any animations after the first aren't seen by the client.

Any ideas?

Note: BoolIfAttacked is just used to see if the zombie is attacking

Double Note: We are going for a combat system similar to runescape

GIF OF WHAT IS HAPPENING HERE - https://gyazo.com/1fd951ff83533f6566ca8a76e2c575a2


function onRunning(speed)
	if script.parent.BoolIfAttacking.Disabled ~= true then
		if speed > 0.01 then
			local scale = 15.0
			playAnimation("walk", 0.1, Humanoid)
			setAnimationSpeed(speed / scale)
			pose = "Running"
		else
			playAnimation("idle", 0.1, Humanoid)
			pose = "Standing"
		end
	else
		pose = "Standing"
			playAnimation("handslap", 0.1, Humanoid)
			currentAnimTrack.Looped = true;
			currentAnimTrack:GetMarkerReachedSignal("DealDamage"):Connect(function()
				local target = script.Parent.Script.Value.Value
				local attacking = false
				if (target ~= nil) and attacking == false then
					attacking = true
					target.Humanoid.Health = target.Humanoid.Health - 1
					wait(1)
					attacking = false
				end
			end)
	end
end

1 answer

If I recall correctly, clients won't see looped animations unless the animation was set to Looped in the editor (changing it in the script doesn't work).

Also, your attacking variable on line 18 is local to the function call -- if you call the function again, you get a new attacking variable, meaning it will always be false on line 19. You should declare it local outside the function (before line 1).

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