Event not Firing?

I tried firing this event but it doesn’t work on the server firing it

here is the firing code

Tool.Equipped:Connect(function()
	-- Make Motor 6D {first we need the player's character}
	local Character = script.Parent.Parent.Parent.Parent.Parent
	local Player = game.Players:GetPlayerFromCharacter(Character)
	local RightHand = Character.RightHand
	
	-- Creation of Motor6D
	local Motor6D = Instance.new("Motor6D")
	Motor6D.Name = "Motor6D"
	Motor6D.Parent = RightHand
	
	Motor6D.Part0 = RightHand
	Motor6D.Part1 = Tool.SwordHandle
	
	PLAY_ANIMATION_EVENT:FireClient(Player, "Hold")
	CHANGE_MOUSE_EVENT:FireClient(Player, "WeaponMouseIcon")
	
end)

then the connector event in the Client

PLAY_ANIMATION_EVENT.OnClientEvent:Connect(function(AnimationName)
	if AnimationName == "Hold" then
		local HOLD_ANIMATION_TRACK = Humanoid:LoadAnimation(HOLD_ANIMATION)
		
		-- Play it bruh lol
		print("working")
		HOLD_ANIMATION_TRACK:Play()
	elseif AnimationName == "Swing" then
		local SWING_ANIMATION_TRACK = Humanoid:LoadAnimation(SWING_ANIMATION)
		local HOLD_ANIMATION_TRACK = Humanoid:LoadAnimation(HOLD_ANIMATION)
		
		-- Play it bruh lol
		print("working")
		HOLD_ANIMATION_TRACK:Stop()
		SWING_ANIMATION_TRACK:Play()
	end
end)

Can you insert a print() in your server script?

yes and the server-sided code works except for the client code it doesn’t work

It would help if we could see more client code, and if you added some prints in the cases it doesn’t work and before the event connection is set up. If it works on the server then either the server is firing before the client script is set up (but it is an equip so it should be fine), or the client is being held up somewhere (maybe you have a loop above the client code you have shown?)

you are correct I did have a while loop but its for my scripting purposes without it is useless

If there’s a while loop before the event detector then the script will never get to the detector. Wrap it in a corountine.wrap() or spawn function

1 Like