WaitForChild does NOT work

The issue is that no matter what I do, location where to put the item is not found in the ModuleScript I use to manage shop items.
image

local sS = game:GetService("ServerStorage")

task.wait(5)

local module = {
	["Cafeteria"] = {
			BloxyCola = {
				InstName = "BloxyCola",
				DisplayName = "Bloxy Cola", -- Name to Display
				Description = "A refreshing cold drink.",
				Location = sS:WaitForChild("ShopItems"),
				ItemImage = 578766873,
				Price = 10;	
			};
		
	};
	--["ShadyDealer"] =  
}

return module

The shop gui:

local shopSys = require(game:GetService("ReplicatedStorage"):WaitForChild("ShopSys"))
local frame = script.Parent
local image = frame:WaitForChild("Image")
local name = frame:WaitForChild("Name")
local desc = frame:WaitForChild("Desc")
local button = frame:WaitForChild("BuyButton")
local PurchaseEvent = game:GetService("ReplicatedStorage").Purchase
local players = game.Players


local instName = shopSys.Cafeteria.BloxyCola.InstName
local ImageID = shopSys.Cafeteria.BloxyCola.ItemImage
local NameText = shopSys.Cafeteria.BloxyCola.DisplayName
local DescText = shopSys.Cafeteria.BloxyCola.Description
local price = shopSys.Cafeteria.BloxyCola.Price
local loc = shopSys.Cafeteria.BloxyCola.Location

task.wait(0.1)
image.Image = ("rbxassetid://"..ImageID)
name.Text = NameText
desc.Text = DescText

button.Activated:Connect(function()
	local result = players.LocalPlayer:FindFirstChild("leaderstats"):WaitForChild("Flux").Value >= price
	PurchaseEvent:FireServer(price,result,instName,loc)
end)

I’m growing desperate…

image

Infinite yield possible on 'ServerStorage:WaitForChild("ShopItems")'

I’m assuming this is a LocalScript? The client cannot access ServerStorage or ServerScriptService.

this is bad very bad please change to game:GetService("Players")
it’s more reliable and nicer to look at

1 Like

That has been answered by a friend already! Also, thanks.

Appreciate your help though.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.