Hello all, I am creating a World-Base multiplayer RPG Adventure Zombie game, and I've run into a SERIOUS problem!

My pop-up shop gui won't work! I can get the GUI to pop-up when the player touches the appropriate brick, but the ImageButtons in the SHOP GUI do NOT function as coded, and I cannot see as to why! The error I sometimes get(not all the time), is that "Chips is not a valid member of IntValue", But the code, without errors, creates the proper folder, and "Chips" IS a proper IntValue according to the test!

Here's my Shop UI code:

script.Parent.MouseButton1Click:Connect(function()
	local RS = game:GetService("ReplicatedStorage")
	local item = RS:WaitForChild("Glock")
	local price = 250
	local player = game.Players.LocalPlayer
	local stats = player:WaitForChild("leaderstats")
	
	if stats.Chips.Value>=price then
		stats.Chips.Value = stats.Chips.Value - price
		local cloned = item:Clone()
		cloned.Parent = player.Backpack
		cloned.Parent = player.StarterPack
	end
end)

Here is my leaderstats code:

game.Players.PlayerAdded:Connect(function(plr)
	local fold = Instance.new("Folder", plr)
	fold.Name = "leaderstats"
	local val = Instance.new("IntValue", fold)
	val.Name = "Chips"
end)


while true do
	wait(5)
	for i, v in pairs (game.Players:GetChildren ()) do
		if v:FindFirstChild ("leaderstats") ~= nil then
			if v.leaderstats:FindFirstChild("Chips") ~= nil then
				v.leaderstats.Chips.Value = v.leaderstats.Chips.Value + 1000
			end
		end
	end
end

4 comments

0

i some times have it to the it says not a member of something, then i put in the begin a wait(3) and they it wont do that any more becourse the 2 script a even as it come to fast writhing so while the first looks for the chips the other still has to make it so let the player add go first and put in the other at first wait(sec) so the addplayer have time to make the chips value

0

or but in the other script also waitforchilderen on the chips

0

cloned.Parent = player.Backpack 12 cloned.Parent = player.StarterPack this isnt richt, at first u put it in the backpack and then u put it in the starterspack so u moved it fro backpack to starterspack

0

Is there any way you could put this in an answer? It’s easier to read, then I can accept and give you the points!