Local Script firing wrong remote function

I am making a simulator shop, and I have two remotes for each thing to buy: like a tool(that gives strength) and storage.
However, when I press “Buy” and I want to buy something other than tool , it fires the tool remote anyway. Please help:

Local script:

buy.Activated:Connect(function()
--ignore anything else, just focus on the result
	if selectedTemp ~= nil and storageSelectedTemp == nil then
		local result = Shared.Remotes.BuyTool:InvokeServer(selectedTemp.Name)
	elseif selectedTemp == nil and storageSelectedTemp ~= nil then
		local result = Shared.Remotes.BuyStorage:InvokeServer(storageSelectedTemp.Name)
	end
end)

I don’t think I need to give the server script, however I will let you know that it cannot run because it searches in the folder for the storageName, but it cannot find as it runs the wrong remote.

1 Like

This is due to selectedTemp and storageSelectedTemp, for whatever reason. Could you give us more insight on how those two values work? What are they and when are they changed?

1 Like

When a player selects a template (like when you click on an item in the shop and it shows its info and stuff) the selectedTemplate becomes the template.