Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

"cash is not a valid member of Folder" why is this happend?

I want to make shop script and i test it and this error show me "cash is not a valid member of "Folder i put the codes

game.Players.PlayerAdded:Connect(function(player)
	local leaderstats= Instance.new("Folder")
	leaderstats.Name = "leaderstats"
	leaderstats.Parent = player

	local cash= Instance.new("NumberValue")
	cash.Name="cash"
	cash.Value = 1000000
	cash.Parent=leaderstats
end)

this name is leaderstats and another

game.ReplicatedStorage.Toolevents.Akevent.OnServerEvent:Connect(function(player)
	if player.leaderstats.cash.Value >= 5000 then
		player.leaderstats.cash.Value = player.leaderstats.cash.Vaule - 5000
		game.ServerStorage.Tools.Ak.Clone().Parent = player.Backpack
	end
end)

is this is named Buytools pls help me

4 comments

0
  1. Please put it on a code block. 2. You spelt Value wrong on the buy tool script.
0

ok

0

idk how i can put in black but here

0

I put a better version of how to do it...

2 answers

So what you are supposed to do is this:

game:GetService("Players").PlayerAdded:Connect(function(plr)
	
	local leaderstats = Instance.new("Folder", plr)
	local leaderstats.Name = "leaderstats"
	
	local Cash = Instance.new("NumberValue", leaderstats) --The difference between NumberValue and IntValue is that NumberValue has decimals and IntValue doesn't
	Cash.Name = "Cash"
	Cash.Value = 1000000
end)


-- Buy Tool thing



game.ReplicatedStorage.Toolevents.Akevent.OnServerEvent:Connect(function(plr)
	local function checkForToolBackPack()
		for i, v in pairs (plr.Backpack) do
			if v.Name == --[[the name of the tool]] then
				return true
			else
				return false
			end
		end
	end
	
	local function checkForToolCharacter()
		for i, v in pairs (plr.Character) do
			if v.Name == --[[the name of the tool]] then
				return true
			else
				return false
			end
		end
	end
	
	local Tool = --Put the location of the tool
	
	local hasToolBa = checkForToolBackPack()
	local hasToolCh = checkForToolCharacter()
	
	if plr.leaderstats.Cash.Value >= 5000 and hasToolB == false and hasToolC == false then
		local ToolClone = Tool:Clone()
		
		Tool.Parent = plr.Backpack or plr.Character
	end
end)

Hope it helped.

3 comments

0

If you want to use this than you can even though your problem has been solved.

0

ok i try it thank you

0

No problem!

This discussion is preserved as it was. New answers, comments, and votes are closed.