Mail.ruПочтаМой МирОдноклассникиВКонтактеИгрыЗнакомстваНовостиКалендарьОблакоЗаметкиВсе проекты

Что не так со скриптами? Roblox Studio

Бондаренко Иван Знаток (470), открыт 1 неделю назад
Появляется ошибка что такого элемента нет в таблице playerData. Помогите пожалуйста. Вот скрипты которые отвечают за playerData:

 local ReplicatedStorage = game:GetService("ReplicatedStorage") 
local towers = require(ReplicatedStorage:WaitForChild("TowerShop"))

local getDataFunc = ReplicatedStorage:WaitForChild("GetData")
local InteractItemFunc = ReplicatedStorage:WaitForChild("InteractItem")

local gui = script.Parent
local exit = gui.Container.Exit
local coins = gui.Container.Coins
local limit = gui.Container.Limit
local itemsFrame = gui.Container.ItemsFrame
local itemBuyTower = gui.Container.ItemsFrame

local playerData = {}

local function getItemStatus(itemName)
if table.find(playerData.SelectedTowers, itemName) then
return "Equipped"
elseif table.find(playerData.OwnedTowers, itemName) then
return "Owned"
elseif table.find(playerData.OwnedTowers, itemName) ~= nil then
return "For Sale"
end
end

local function interactItem(itemName)
local data = InteractItemFunc:InvokeServer(itemName)
end

local function updateItems()
coins.Text = playerData.Coins
limit.Text = #playerData.SelectedTowers .. "/5"

for i, tower in pairs(towers) do

local oldButton = itemsFrame:FindFirstChild(tower)
if oldButton then
oldButton:Destroy()
end

local newButton = itemsFrame.TemplateButton:Clone()
newButton.Name = tower.Name
newButton.TowerName.Text = tower.Name
newButton.Image = tower.ImageAsset
newButton.Visible = true
newButton.Parent = itemsFrame

newButton.Activated:Connect(function()
itemBuyTower.Visible = true

local oldPldButton = itemBuyTower:FindFirstChild(tower.Name)
if oldPldButton then
oldPldButton:Destroy()
end

local oldPldButton = itemBuyTower:GetChildren()
for x,o in pairs(oldPldButton) do
if not o:IsA("UICorner" or "UIAspectRatioConstrain") then
if o:IsA("ImageButton") and o.Visible == true then
o:Destroy()
end
end
end

local pldButton = itemBuyTower.TemplateButton:Clone()
pldButton.Name = tower.Name
pldButton.TowerName.Name = tower.Name
pldButton.Desc.Text = "".. tower.Description
pldButton.Image = tower.ImageAsset
pldButton.LayoutOrder = tower.Price
pldButton.Visible = true
pldButton.Parent = itemBuyTower

local status = getItemStatus(tower.Name)
if status == "For Sale" then
pldButton.Status.Text = "$:".. tower.Price
pldButton.Status.BackgroundColor3 = Color3.new(1,0,0)
elseif status == "Equipped" then
pldButton.Status.Text = "Equipped"
pldButton.Status.BackgroundColor3 = Color3.new(0,1,0)
end

pldButton.Status.Activated:Connect(function()
interactItem(tower.Name)
end)
end)

end
end

local function toggleShop()
gui.Container.Visible = not gui.Container.Visible
if gui.Container.Visible then
itemBuyTower.Visible = false
playerData = getDataFunc:InvokeServer()
updateItems()
end
end

local function setupShop()

end

(2 скрипт не получается вставить)
0 ответов
Похожие вопросы