So I want to send data from the server to the client to send a system message because that doesn't work in a server script, and when I do FireClient in the server script, the last argument (assettype) is nil. I printed it in the server and it was not nil.

--Server

Amount=Amount+1
		Sound.Volume = 0
		Sound:Stop()
		local Asset = game:GetService("MarketplaceService"):GetProductInfo(msg:match'%d+')
		if Asset.AssetTypeId == 3 then
			warn("Audio change info")
			print("player_name: ".. plr.Name)
			print("asset_name: "..Asset.Name)
			print("asset_id: "..msg:match'%d+')
			print("server_audio_change_amount: ".. Amount)
			Sound.SoundId='rbxassetid://'..msg:match'%d+'
			Sound:Play()
			Sound.Volume = 0
			for i = 1,15 do
				wait()
				Sound.Volume = Sound.Volume + 0.05
			end
			Sound.Volume = 0.75
			game:GetService("ReplicatedStorage").SongChangeEvent:FireClient(plr,true,Asset.Name,msg:match'%d+')
		else
			warn("Invalid ID, "..msg:match'%d+')
			print("asset_type: ".. Asset.AssetTypeId)
			print("asset_name: "..Asset.Name)
			Sound.Volume = 0.75
			print(Asset.AssetTypeId) --Output: not 3 (see wiki for all asset types)
			game:GetService("ReplicatedStorage").SongChangeEvent:FireClient(plr,false,Asset.Name,msg:match'%d+') --what i'm currently trying to fix
		end
--Client

CreateMessage = function(text, color, font, size)
	game.StarterGui:SetCore("ChatMakeSystemMessage", {
		Text = text;
		Color = color;
		Font = font;
		FontSize = size;
	})
end
game:GetService("ReplicatedStorage").SongChangeEvent.OnClientEvent:Connect(function(player,valid,soundname,soundid,assettype)
print(assettype) --Output: nil
	if valid == true then
		CreateMessage(player.Name.." requested a song. Now playing | "..soundname.." ["..soundid.."]",Color3.new(0.6,1,0.6),Enum.Font.SourceSansBold,24)
	else
		CreateMessage("Invalid asset type or banned (Requested asset info | ID: "..soundid..", Asset type: "..assettype", Asset name: "..soundname..")",Color3.new(1,0.6,0.6),Enum.Font.SourceSansBold,24) --message with assettype
	end
end)

2 comments

0

i realized i forgot to put in the asset type in FireServer, but it still doesnt work

0

and i solved this problem myself