String being lost OnServerEvent..?

For some reason, “saveFileName” is becoming nil when it is printed through the server script (in the .OnServerEvent).

MODULE SCRIPT

function PropPlacerButtons.SaveButton(player, saveFileName)
	print(saveFileName)
	saveEvent:FireServer(player, saveFileName)
end

SERVER SCRIPT

saveEvent.OnServerEvent:Connect(function(player, saveFileName) -- when player presses button
	print(saveFileName)
	local userId = player.UserId
	local playerName = player.Name

	-- save props to session data
	local myProps = {}

	for _, prop in playerProps[playerName]:GetChildren() do
		local propName = prop.Name

		table.insert(myProps, SerializeProp(prop))
	end
	sessionData[userId]["PropData"][saveFileName] = myProps
end)

Yes the code is working, it’s just that value becoming nil. It is not nil when it’s in the modulescript.

Found out it’s because the ‘player’ argument in the module script is not necessary and it overwrites the saveFileName, woopsies!

1 Like

:FireServer does not need a player argument.

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