Remote Event parameter returns nil when printed

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!
    I want print what is in the second parameter.

  2. What is the issue? Include screenshots / videos if possible!
    When every I print the second parameter, I get a nil value.

  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    I’ve looked for other solutions, but from everything I’ve seen nothing relates to my issue.

for _, Item in pairs(Stored:GetChildren()) do
		if Item:IsA("Frame") or Item.Name == "ItemName"  then
			ListItem.TakeBtn.MouseButton1Click:Connect(function()
				print(Item) -- this print "ItemName"
				wait()
				reStorage.TakeFromStored:FireServer(humanoid, Item)
			end)
		end
	end
local storage = game.ReplicatedStorage
storage.TakeFromStored.OnServerEvent:Connect(function(player, humanoid, FoodItem)
	print(FoodItem) -- this print "nil"
3 Likes

its possible that the item got deleted during the fireserver, or the item only exists on the clientside, could you maybe explain a little more how it works?

i experienced this before, i ended up firing the instance name to the server and make the server find the instance by the name. i hope i could find a better answer here.

I have a frame titled “stored” with frames titled “ItemName”, I looped through the stored frame and it printed just fine, but when I try to find the frames with a button and print it says nil. I’m also unsure how item got deleted or if the item only exists on the clientside because I’m new to scripting

1 Like

could you tell me if the frames in “stored” are placed by a LocalScript? if yes, that means that its running on the clientside, so the server wont detect it, if not, then i don’t really know how to help

Yes, all the frames are place by a localScript

i see, a quick fix would be transforming it into a normal script, unless it needs to be ran as a local script. can you send it to me so i can see how it works exactly?

This is how the frames in the stored frame are made, the rest of the LocalScript works fine

for _, tool in pairs(Stored) do --- loops through a folder in the players backpack
		local Item = Template:Clone()
		Item.Parent = Stored
		Item.FoodName.Text = tool.Name
		Item.Visible = true
	end
end

This is the script for the Remote Event

local storage = game.ReplicatedStorage

storage.TakeFromStored.OnServerEvent:Connect(function(player, humanoid, FoodItem)
	print(FoodItem)
end)

i think you can just turn it into a normal script, copy the code, delete the localscript where the item is added to “stored”, add a server script in the same place and paste the code inside of it, you may need to do a little tweaks here and there, but dont worry, to get the player in a server script, considering you’re using a GUI, just use script.Parent and repeat “.Parent” until you reach DataModel

What is FoodItem; is it an object or a string? If it’s an object created on the Client then the Server won’t recognize it because of replication. You’re better off using unique strings and names to identify what you’re looking for on the server.

I think its a parameter in the Remote Event

Ok, I try this when I get the chance

If Item was created in a LocalScript, then only your client can access it, and not the server. You could probably send the Item.Name instead of Item.

1 Like

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