What did i do wrong?

Module Script

function Emotes.GetData(player: Player)
	local key = "index_" .. player.UserId
	local data = EmoteSaving:GetAsync(key)
	if data then
		EmoteAquiring:FireClient(player, data)
		print("Emote data sent: ", data)
	else
		print("No emote data found for player: " .. player.Name)
	end
end
local Template = script.EmoteTemplate
local EmoteAquiring = game.ReplicatedStorage.returnFunction:WaitForChild("EmoteAquiring")

if Template then
	EmoteAquiring.OnClientEvent:Connect(function(player, index)
		if player then
			if not index then
				print(index)
			end

			if index then
				for _, i in ipairs(index) do
					local newTemplate = Template:Clone()
					newTemplate.Parent = script.Parent

					newTemplate.Name = i
					newTemplate.EmoteName = i
				end
			end
		end
	end)
end

It always prints “nil”. Did i perchance do something wrong?

Couple of issues:

  • OnClientEvent does not provide the player as the first argument (as it will always be the local player). Remove player from function(player, index) and it should fix the main issue.

  • You only ever output when index is nil. Try removing the if not index then condition, and just always output index

1 Like

excuse my late reply sir, it works now, thank you so so much, it took me so long of trying, thank you once again.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.