so im making a shop and 'attempt to index nil with 'name'' keeps coming up
here is my code
local ReplicatedStorage = game:GetService('ReplicatedStorage') local remoteEvent = ReplicatedStorage:WaitForChild('BuyTool') local function buyTool(player, tool) local giveTool = ReplicatedStorage.ShopItems[tool.name]:Clone() giveTool.Parent = player.Backpack local giveTool = ReplicatedStorage.ShopItems[tool.name]:Clone() giveTool.Parent = player.StarterGear end remoteEvent.OnServerEvent:Connect(buyTool)
The problem is you didn't use name with a capital
Try this
local ReplicatedStorage = game:GetService('ReplicatedStorage') local remoteEvent = ReplicatedStorage:WaitForChild('BuyTool') local function buyTool(player, tool) local giveTool = ReplicatedStorage.ShopItems[tool.Name]:Clone() giveTool.Parent = player.Backpack local giveTool2 = ReplicatedStorage.ShopItems[tool.Name]:Clone() giveTool2.Parent = player.StarterGear end remoteEvent.OnServerEvent:Connect(buyTool)