Shop GUI not working (error)

Hi,
So I made a shop where you can buy tools from, but when I purchase a tool, I don’t get the item. Money does go from my balance, but I receive nothing.

When the item is bought, I get this error in the output: "0 is not a valid member of Folder "ReplicatedStorage.Tools"

When I click on the error, it leads to this script in ServerScriptService:
image

1 Like

It seems that you are passing incorrect arguments to your remote event. The “Tool” variable is set to 0 which is not a valid Instance in your Tools folder.

2 Likes

Please show the script that is firing the event as well please!

2 Likes

As @player356377 said, you are passing the number 0 as the tool, instead of a string.

And if your money management is done though a local script
(Money gets removed when player purchases something, client then tells server to give item, after removing money)
That just means exploiters can easily get the best items in the game, as you would have no server sided verification.

Hi, I don’t want to worry about any exploiters. Could you help me prevent that? This is how the currency decreases with my local script in GUI.

local Tool = script.Parent.Tool.Value

script.Parent.MouseButton1Click:Connect(function(player)
	if game.Players.LocalPlayer.leaderstats.Money.Value >= script.Parent.Cost.Value then
		game.Players.LocalPlayer.leaderstats.Money.Value = game.Players.LocalPlayer.leaderstats.Money.Value - script.Parent.Cost.Value
		game.ReplicatedStorage.Events.RemoteEvent:FireServer(Tool, player)
		script.Parent.ToolName.Text = "Success!"
		wait(3)
		script.Parent.ToolName.Text = "Bread"
	else
		script.Parent.ToolName.Text = "Not enough coins!"
		wait(3)
		script.Parent.ToolName.Text = "Bread"
	end
end)
1 Like

Hi! So how could I potentially fix this?

Hi,

Here it is:

local Tool = script.Parent.Tool.Value

script.Parent.MouseButton1Click:Connect(function(player)
	if game.Players.LocalPlayer.leaderstats.Money.Value >= script.Parent.Cost.Value then
		game.Players.LocalPlayer.leaderstats.Money.Value = game.Players.LocalPlayer.leaderstats.Money.Value - script.Parent.Cost.Value
		game.ReplicatedStorage.Events.RemoteEvent:FireServer(Tool, player)
		script.Parent.ToolName.Text = "Success!"
		wait(3)
		script.Parent.ToolName.Text = "Bread"
	else
		script.Parent.ToolName.Text = "Not enough coins!"
		wait(3)
		script.Parent.ToolName.Text = "Bread"
	end
end)

Check the value of your script.Parent.Tool variable and make sure that the name of the tool is correct. Regarding the issue with exploiters, check if a player has the required money and subtract it inside your Server Script. Exploiters can only modify their own client (Local side) and can not access the server.

I think you shall check or print the value before and after transforming. Sometimes Studio will accidently change the type of value, like number or string, as “0” is not the same as 0.

try this

local Storage = game:GetService("ReplicatedStorage")
local RemoteEvent = Storage.Events.RemoteEvent

local function BoughtTool(player,ToolValue)
      for i,v in pairs(Storage.Tools:GetChildren()) do
            if v.Tool.Value == ToolValue then
            local Tool = v:Clone()
            Tool.Parent = player.Backpack
       end
    end
end

@madonchik123
This will not resolve the presented issue. The issue with the script is that the “Tool” variable passed is incorrect in addition to the script being vulnerable to exploits, both of which this script will not fix.

then its his localscript error

I tried this, but I still don’t get the item in my inventory.

1 Like

any errors? or smh like that if yes then send them

@Nabilekes
As mentioned in my post below his script, this wont fix your issue.

Try this instead:

I have checked the value, and it’s 15, so I get the error:

15 is not a valid member of Folder "ReplicatedStorage.Tools" 

I tried changing the value to the name of the tool, but it seems like it won’t allow letters.

Make sure the variable instance is a String Value and then type in the name of the tool.

Oh, okay, but how do I do that?

Open the insert object menu and type StringValue into the search field.
image

Oh, but I already have that, it’s called Tool.

EDIT: The value of that tool is 15

Screenshot 2022-09-17 at 13.54.13