Hello Devs I’m currently making a simulator shop, also the code is from HowToRoblox and just made it into remote function, anyways I have a problem, when I try to invoke the name of the item it just prints nil I don’t know why it’s not getting the item name why is that? I tried to look solutions in the dev forum but can’t find what I’m looking for.
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local TweenService = game:GetService("TweenService")
local remotes = ReplicatedStorage:WaitForChild("Remotes")
local drinksFrame = script.Parent:WaitForChild("DrinksFrame")
local itemListFrame = drinksFrame:WaitForChild("ItemListFrame")
local itemList = itemListFrame:WaitForChild("ItemList")
local itemView = drinksFrame:WaitForChild("ItemView")
local itemStats = itemView:WaitForChild("Stats")
local drinks = ReplicatedStorage:WaitForChild("Drinks")
for i, item in pairs(drinks:GetChildren()) do
local name = item.Name
local amount = item.Amount
local price = item.Cost
local itemButton = script.Item:Clone()
itemButton.Name = name
itemButton.LayoutOrder = price.Value
local cam = Instance.new("Camera")
cam.Parent = itemButton.ViewItem
itemButton.ViewItem.CurrentCamera = cam
local displayItem = item.Handle:Clone()
displayItem.Anchored = true
displayItem.Parent = itemButton.ViewItem
cam.CFrame = CFrame.new(displayItem.Position + displayItem.CFrame.LookVector * 2, displayItem.Position)
itemButton.Parent = itemList
itemButton.MouseButton1Click:Connect(function()
--// Deletes handle and camera if it already exist
if itemView.ItemPreview:FindFirstChild("Handle") then itemView.ItemPreview.Handle:Destroy() end
if itemView.ItemPreview:FindFirstChild("Camera") then itemView.ItemPreview.Camera:Destroy() end
local itemName = itemStats:WaitForChild("ItemName")
itemName.Text = name
itemStats.Amount.Text = "+" .. amount.Value .. " Drinks"
itemView.Price.Text = price.Value .. " Drinks"
local cam2 = Instance.new("Camera")
cam2.Parent = itemView.ItemPreview
itemView.ItemPreview.CurrentCamera = cam2
cam2.CFrame = CFrame.new(displayItem.Position + displayItem.CFrame.LookVector * 2, displayItem.Position)
displayItem:Clone().Parent = itemView.ItemPreview
itemView.Visible = true
end)
end
remotes.Events.OpenShop.OnClientEvent:Connect(function(player)
drinksFrame.Size = UDim2.new(0.05, 0, 0.05, 0)
drinksFrame.Visible = true
drinksFrame:TweenSize(UDim2.new(0.65, 0, 0.8, 0), Enum.EasingDirection.Out, Enum.EasingStyle.Sine, 0.15)
end)
drinksFrame.Exit.MouseButton1Click:Connect(function()
drinksFrame.Visible = false
remotes.Events.CloseShop:FireServer()
end)
itemView.Buy.MouseButton1Click:Connect(function()
local result = ReplicatedStorage.Remotes.Functions.OnItemPurchase:InvokeServer(drinks[itemStats.ItemName.Text])
print(result)
end)