Hello Developers,
I have a script in my game that takes all of the seeds that are in the game (From a table in a module script) and makes GUIs for them in the shop when a player joins, but for some reason the GUIs aren’t added.
Script (server):
local players = game.Players
local cropHandler = require(game.ServerScriptService.CropHandler)
--Setup shop
players.PlayerAdded:Connect(function(player)
task.wait(1)
for i = 1, #cropHandler.CropInfo, 1 do
local templateClone = game.ReplicatedStorage.SeedGuiTemplate:Clone()
templateClone.Name = cropHandler.CropInfo[i]
print(cropHandler.CropInfo[i])
templateClone.Parent = player.PlayerGui.SeedsGui.Shop.Frame.Main.SeedDisplay
templateClone.Main.SeedsImage.SeedName.Text = cropHandler.CropInfo[i]
templateClone.Main.SeedsImage.SeedPrice.Text = "$"..tostring(cropHandler.CropInfo[i].Cost)
end
end)
Here is the CropHandler (module):
local CropHandler = {}
CropHandler.CropInfo = {
["Wheat"] = {
ExpGiven = 1,
CoinsGiven = 1,
GrowingTime = 15,
Cost = 0,
Image = ""
},
["Carrot"] = {
ExpGiven = 2,
CoinsGiven = 3,
GrowingTime = 25,
Cost = 20,
Image = ""
},
["Tomato"] = {
ExpGiven = 3,
CoinsGiven = 6,
GrowingTime = 35,
Cost = 40,
Image = ""
},
["Beet"] = {
ExpGiven = 2,
CoinsGiven = 2,
GrowingTime = 25,
Cost = 40,
Image = ""
},
["Pumpkin"] = {
ExpGiven = 4,
CoinsGiven = 10,
GrowingTime = 40,
Cost = 70,
Image = ""
},
["Pepper"] = {
ExpGiven = 3,
CoinsGiven = 6,
GrowingTime = 30,
Cost = 70,
Image = ""
},
["Corn"] = {
ExpGiven = 5,
CoinsGiven = 15,
GrowingTime = 60,
Cost = 100,
Image = ""
},
["Evergreen"] = {
ExpGiven = 7,
CoinsGiven = 20,
GrowingTime = 120,
Cost = 160,
Image = ""
}
}
return CropHandler
Here are what the GUI objects look like in the Explorer:
There aren’t any output errors.
Please help!