Not A Valid Member Of Folder

17:31:22.864 - Value is not a valid member of Folder This error comes up for both ServerScript and local script

Local script

local replicatedStorage = game:GetService("ReplicatedStorage")--Defines replicated storage
local selectedItem = script.Parent.Parent.Parent:WaitForChild("SelectedItem")--Defines what selectedItem is

local success--Variable

script.Parent.MouseButton1Click:Connect(function()
	
	success = false--Makes success false
	if selectedItem.Value ~= nil then--If the value isn't equal to nil
		selectedItem.Value = script.Parent.Parent.Name
		print(selectedItem.Value)
		success = replicatedStorage.CheckSale:InvokeServer(selectedItem.Value)--Make a request to the remote function
	end
	
	if success then
		print("Purchased!")
		
	else
			
			print("Purchase Failed!")
	end
	
end)

ServerScript

local replicatedStorage = game:GetService("ReplicatedStorage")--Defines replicated storage
local shopItems = game:GetService("ServerStorage"):WaitForChild("ShopItems")--Defines the items in ServerStorage


replicatedStorage.CheckSale.OnServerInvoke = (function(player,item)--Responds to the remote function  request
	
	local price = shopItems[item].Value.Value--Defines the price of the item
	
	if player.leaderstats.Value.Value >= price then--Check to see if the player has enough money
		
		player.leaderstats.Points.Value = player.leaderstats.Points.Value - price--Subtracts the price
		
		local gear = shopItems[item[item]]:Clone()--Clones the item they bought
		gear.Parent = player.Backpack--Put the clone in their backpack
		
		
		return true
	else
			return false
	
	end
end)

1 Like

Are you sure you are not calling the Value property from a Folder instance?

I dont think his problem is here

Value either isn’t a child of

or

Double check all your shop items contain the value.

Also, local gear = shopItems[item[item]]:Clone() should be
local gear = shopItems[item][item]:Clone()

I know this problem, it happend to me before, it is just because he group the folder/script try ungroup them… and see if it works

I wish this helps

I’m calling it from a folder instance

What do you mean by

This text will be blurred

Can you take a screenshot of your explorer pertaining to this issue?

You can try the :WaitForChild() method. Or you can use brackets to surround the child.

Such as Part:WaitForChild(“Folder”) or Folder[“Value”],

1 Like

Mate check the script/value they are in group/ also send some pictures about ur problem… I did not fully understand

I added a picture, let me know if you want to see anything else

alr i will check it and see if i can help

I think It is because that you didn’t select the items, in the script. idk i have no idea it shall work everything was correct…

So I noticed you said that same error comes up for both server and client?? Is that suggesting (selectedItem) isn’t a value but a folder? I’m unsure about some of this context so maybe send a image of all the client and server depends on to run your code and I’ll have a better understanding.

Edit: To make sure maybe have a test print along the lines of

print(selectedItem.ClassName)

This is where the issue is. You put player.leaderstats.Value.Value instead of
player.leaderstats.Points.Value

@RudraVII yeah you’re right in this point…

but he said both scripts not work

To fix it for client, he’d have to change it from .Value to :FindFirstChild(“Value”) in the if statement where he is checking if Value is nil or not.

selectedItem is a StringValue

Oh I see, you put made a typo that I overlooked in the server side.

if player.leaderstats.Value.Value >= price then--Check to see if the player has enough money
local data_store_name = "NoPeeking" -- never share your datastore name with ANYONE!
local ds = game:GetService("DataStoreService"):GetDataStore(data_store_name)

local function join(plr)
  -- leaderstats script
  -- Do NOT add this part if you already have a leaderstat script!

    local leaderstats = Instance.new("Folder")
    leaderstats.Name = "leaderstats"
    leaderstats.Parent = plr
    
    local gold = Instance.new("IntValue")
    gold.Name = "Gold"
    gold.Value = 0
    gold.Parent = leaderstats
    
    local elixir = Instance.new("IntValue")
    elixir.Name = "Elixir"
    elixir.Value = 0
    elixir.Parent = leaderstats

    local darkElixir = Instance.new("IntValue")
    darkElixir.Name = "Dark Elixir"
    darkElixir.Value = 0
    darkElixir.Parent = leaderstats
    
    -- Add this part no mater what!
    local data1 
    local data2
    local data3

    local suc, err = pcall(function()
      -- you can add more if you ever want to
      data1 = ds:GetAsync(plr.UserId.."_gold")
      data2 = ds:GetAsync(plr.UserId.."_elixir")
      data3 = ds:GetAsync(plr.UserId.."_darkElixir")
  end)

  if suc then
      plr.leaderstats.Gold.Value = data1
      plr.leaderstats.Elixir.Value = data2
      plr.leaderstats:FindFirstChild("Dark Elixir").Value = data3
  else
    warn("Couldn't get ".. plr.Name .. "'s data.\n", err)
  end
end

local function leave(plr)
  local suc, err = pcall(function()
    -- If you added any extra values at top, remember to add them here!
    ds:SetAsync(plr.UserId.."_gold", plr.leaderstats.Gold.Value)
    ds:SetAsync(plr.UserId.."_elixir", plr.leaderstats.Elixir.Value)
    ds:SetAsync(plr.UserId.."_darkElixir", plr.leaderstats:FindFirstChild("Dark Elixir").Value)
  end)

  if not suc then
    warn("Couldn't save ".. plr.Name.."'s data.\n".. err)
  end
end

game.Players.PlayerAdded:Connect(join)
game.Players.PlayerRemoving:Connect(leave)

I changed points to gold so can I substitute it like this?

if player.leaderstats.gold.Value >= price then