Cant seem to figure out how to fix the error. Been looking around at other people with same issue and havent had any luck. Any help is appreciated. I β where the error is
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local swords = require(ReplicatedStorage:WaitForChild("SwordShop"))
local player = game:GetService("Players").LocalPlayer
local getDataFunc = ReplicatedStorage:WaitForChild("GetData")
local interactItemFunc = ReplicatedStorage:WaitForChild("InteractItem")
local gui = script.Parent
local exit = gui.GuiShop.Button
local points = gui.GuiShop.PT.Points
local limit = gui.GuiShop.PT.Limit
local itemsFrame = gui.GuiShop.TowerShop.ItemsFrame
local playerData = {}
local function getItemStatus2(itemName) -- i get the error on this line
if table.find(playerData.SelectedSword, itemName) then
return "Equipped"
elseif table.find(playerData.OwnedSwords, itemName) then
return "Owned"
else
return "For Sale"
end
end
local function interactItem(itemName)
local data = interactItemFunc:InvokeServer(itemName)
if data then
playerData = data
updateItems()
end
end
function updateItems()
points.Text = "Points : " .. playerData.Points
for i, sword in pairs(swords) do
local oldButton = gui.GuiShop.TowerShop:FindFirstChild(sword.Name)
if oldButton then
oldButton:Destroy()
end
local newButton = itemsFrame:Clone()
newButton.Name = sword.Name
newButton.TowerName.Text = sword.Name
newButton.Price.Text = sword.Price .. " Points"
newButton.Image.Image = sword.ImageAsset
newButton.Desc.Text = sword.Description
newButton.Type.Text = sword.Type
newButton.Visible = sword.Visible
newButton.LayoutOrder = sword.Price
newButton.Parent = gui.GuiShop.TowerShop
local status = getItemStatus2(sword.Name)
if status == "For Sale" then
newButton.Status.Text = "PURCHASE"
elseif status == "Equipped" then
newButton.Status.Text = "EQUIPPED"
newButton.Price.Visible = false
newButton.PriceLabel.Visible = false
else
newButton.Status.Text = "EQUIP"
newButton.Price.Visible = false
newButton.PriceLabel.Visible = false
end
newButton.Status.Activated:Connect(function()
interactItem(sword.Name)
end)
end
end
local function toggleShop()
gui.GuiShop.Visible = not gui.GuiShop.Visible
if gui.GuiShop.Visible then
playerData = getDataFunc:InvokeServer()
updateItems()
end
end
local function setupShop()
local prompt = Instance.new("ProximityPrompt")
prompt.RequiresLineOfSight = false
prompt.ActionText = "Shop"
prompt.Parent = workspace:WaitForChild("ShopPart2")
prompt.Triggered:Connect(toggleShop)
exit.Activated:Connect(toggleShop)
end
setupShop()