Remote event sending nil even though value is not nil

im trying to send a texture string to the players inventory gui to create a new icon, but its saying the texture is nil even though i print the value im sending before sending it and it prints the value

SERVERSIDE

game.Players.PlayerAdded:Connect(function(player)
	
	player.CharacterAdded:Connect(function(char)
		local pets = petDS:GetAsync(player.userId) or {}
		for i, v in pairs(pets) do
			
			local tex = tostring(v.tex)
			print("texture is ".. tex)
			game.ReplicatedStorage.REs.ADDRAT:FireClient(player,tex)
			
		end 
	end)
	
end)

LOCAL

game.ReplicatedStorage.REs.ADDRAT.OnClientEvent:Connect(function(player,texture)
	print("adding ".. texture .. " to inv")
	local pet = game.ReplicatedStorage.INVPET:Clone()
	pet.Parent = script.Parent
	pet.GUIRAT.Mesh.TextureId = texture
	
end)

ERROR

OnClientEvent does not pass the player parameter since that would be the LocalPlayer. The first parameter is already the texture.

2 Likes

thanks, i dont often pass to clients so i forgot about this!

Alright, so when receiving a value from a Server, the .OnClientEvent 's first parameter is not Player, only when sending Client to Server.

Just switch from

game.ReplicatedStorage.REs.ADDRAT.OnClientEvent:Connect(function(player,texture)

to
game.ReplicatedStorage.REs.ADDRAT.OnClientEvent:Connect(function(texture)
and you’ll be good!

1 Like