I am trying to make a house picker script but I can’t get a child of ServerStorage. I have a workaround, but that is to put the models in the Workspace and that will cause unnecessary lag. Script:
local Event = game.ReplicatedStorage.HouseSelectEvent
local Houses = game.ServerStorage:WaitForChild("Houses")
local C = Houses:GetChildren()
local Sign = game.Workspace.HomeSign
local Players = game:GetService("Players")
local thumbType = Enum.ThumbnailType.HeadShot
local thumbSize = Enum.ThumbnailSize.Size420x420
function SpawnHouse(Player, House, Plot)
for i = 1,#C do
if C[i].Name == House then
local userId = tonumber(Player.UserId)
local clone = C[i]:Clone()
clone.Parent = Plot
clone:MakeJoints()
clone.Door.SurfaceGui.Owner.Text = Player.Name
local content, isReady = Players:GetUserThumbnailAsync(userId, thumbType, thumbSize)
Plot:FindFirstChildWhichIsA("Model").WindowBody.Window.SurfaceGui.ImageLabel.Image = content
clone:SetPrimaryPartCFrame(Plot.CFrame)
else
continue
end
end
end
Event.OnServerEvent:Connect(function(Player, House, PlotNum)
local OwnsHouse = Player:FindFirstChild("OwnsHouse")
local HouseOwned = Player:FindFirstChild("HouseOwned")
Plot = game.Workspace:FindFirstChild("Plot "..PlotNum)
Owner = Plot.Owner
if HouseOwned.Value == "" and (Owner.Value == Player.Name or Owner.Value == "") then
Owner.Value = Player.Name
OwnsHouse.Value = true
HouseOwned.Value = Plot.Name
if Plot:FindFirstChild("HomeSign") then
Plot:FindFirstChild("HomeSign"):Destroy()
end
if Plot:FindFirstChildWhichIsA("Model") then
Plot:FindFirstChildWhichIsA("Model"):Destroy()
end
SpawnHouse(Player, House, Plot)
end
end)
Players.PlayerRemoving:Connect(function(Plr)
if Owner and Owner.Value ~= "" and Plot then
if Owner.Value == Plr.Name then
Plot:FindFirstChildWhichIsA("Model"):Destroy()
Owner.Value = ""
local clone = Sign:Clone()
clone.Parent = Plot
clone:MakeJoints()
clone:SetPrimaryPartCFrame(Plot.CFrame)
end
end
end)
It keeps saying infinite yield on the second line.
Ensure that there isn’t an extra space at the end of the name – this is something that happened in another topic I responded to when something wasn’t able to be found.
Since it appears that you’re trying to access it via a ModuleScript or Server Script (since you have an OnServerEvent function), and if the folder is already there before runtime, I don’t see another reason why it wouldn’t be able to find it.
Do a quick test in studio → while in the test, switch to server view and verify that the contents in ServerStorage actually exist. Screenshot what you see in the test.
Also can you screenshot where the script is located?
From the server view can you verify that you don’t have any other items called “ServerStorage” and that the “Houses” folder exist.
Alternatively, you could also try:
local Houses = game:GetService("ServerStorage"):WaitForChild("Houses")
I know you heard this quite a bit, but are you 100% sure that you aren’t calling it from a local script? or having a local script require a module to do this, etc.
try with :FindFirstChildWhichIsA(“Folder”) if it’s the only folder in SS, if that doesn’t work then it’s acting like you don’t have access to SS for sure