Transferring information with RemoteEvent

Hello everyone. I’m trying to make a delivery system that uses a remote event to send and detect the type of product the player has ordered, the issue is, whenever I try to transmit the information from the local script to the server script trough the remote event, it prints the player instead of the actually information I tried to transfer.
Here are the scripts:

Local Script:

local apname = "A1"
local plr = game.Players.LocalPlayer
local price = script.Parent.Price.Value

script.Parent.MouseButton1Down:Connect(function()
	local delivering = game.Workspace.Apartments:FindFirstChild(apname).DeliverySpot.Box.Delivering	
	script.Parent.UIStroke.Color = Color3.new(0, 0, 0)
	game.SoundService.MClick:Play()

	if delivering.Value == true then
		plr.PlayerGui.Sound.error:Play()
		local tect = game.ReplicatedStorage.NewMoney:Clone()
		tect.Parent = plr.PlayerGui.UI.Frame.SellingBox
		tect.TextColor3 = Color3.new(1, 0.231373, 0.129412)
		tect.Text = "you already have placed an order for a package"
		tect.disappear.Enabled = true
	else
		if plr.leaderstats.Money.Value < 220 then
			plr.PlayerGui.Sound.error:Play()
			local tect = game.ReplicatedStorage.NewMoney:Clone()
			tect.Parent = plr.PlayerGui.UI.Frame.SellingBox
			tect.TextColor3 = Color3.new(1, 0.231373, 0.129412)
			tect.Text = "you do not have enough money"
			tect.disappear.Enabled = true
		else	
			local takemoney = script.Parent.TakeMoney
			takemoney:FireServer(plr)
			
			local typee = "CreamCheese"
			
			local tect = game.ReplicatedStorage.NewMoney:Clone()
			tect.Parent = plr.PlayerGui.UI.Frame.SellingBox
			tect.TextColor3 = Color3.new(1, 0.231373, 0.129412)
			tect.Text = "-".. price.. " $"
			tect.disappear.Enabled = true
			script.Parent.Parent.Parent.Parent.Parent.Parent.Sounds.sell:Play()
			game.ReplicatedStorage.Remotes.Laptops:FindFirstChild(apname.."Delivery"):FireServer(typee)
		end
	end
end)

Server Script:

local name = script.Parent.Parent.Parent.Parent.Name

game.ReplicatedStorage.Remotes.Laptops:FindFirstChild(name..'Delivery').OnServerEvent:Connect(function(typee)
	print(typee)
	if typee == "CreamCheese" then
	
	local box = game.ServerStorage.Shipping.Boxes["Cream Filament Box"]:Clone()
	
	box.Name = name.."Box"
	box.Parent = game.ServerStorage.Shipping.Delivered
	end
end)

The “print(typee)” prints my name instead of the “CreamCheese” variable I set and transferred.

This is because Client → Server events have a built in argument. This built in argument being Player which automatically transfers the client over to the server!

To fix your code, you can do:

game.ReplicatedStorage.Remotes.Laptops:FindFirstChild(name..'Delivery').OnServerEvent:Connect(function(client, typee)
	print(typee)
	if typee == "CreamCheese" then
	
	local box = game.ServerStorage.Shipping.Boxes["Cream Filament Box"]:Clone()
	
	box.Name = name.."Box"
	box.Parent = game.ServerStorage.Shipping.Delivered
	end
end)

Client → Server remote events pass through the following:

path.to.event.OnServerEvent:Connect(function(Player: Player, ... ) -- ... means all of your arguments you are passing through!
    Your.Code.Goes.Here
end

Hope this helped!
1 Like

Worked like clockwork, thank you very much !

No problem!

Glad to lend a helping hand!

1 Like

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