i get 2 swords at one purchase and gives me error
Players.Da_RealHonestmam.Backpack.SwordOfRedEpicness.Script:9: attempt to call a nil value
ServerScriptService.ToolGiver:5: attempt to index nil with ‘Clone’
local Events = ReplicatedStorage:WaitForChild('Events')
local Items = ReplicatedStorage:WaitForChild('Items')
local Purchase = Events:WaitForChild('Purchase')
local PurchaseScreen = script.Parent.Parent.Main:WaitForChild('PurchaseScreen')
local Player = game.Players.LocalPlayer
local Sidebar = script.Parent:WaitForChild('Sidebar')
for _,shop in pairs(Sidebar:GetChildren()) do
if shop:IsA('TextButton') then
shop.MouseButton1Click:Connect(function()
PurchaseScreen.ProductName.Text = shop.Name
PurchaseScreen.Thumbnail.Image = "rbxassetid://"..shop.ImageID.Value
end)
PurchaseScreen.Buy.MouseButton1Click:Connect(function()
if Player.leaderstats.Money.Value >= shop.Price.Value then
local tool = Items:FindFirstChild(shop.Name)
Purchase:FireServer(tool,shop.Price.Value)
end
end)
end
end
server
local ReplicatedStorage = game:GetService('ReplicatedStorage')
local Events = ReplicatedStorage:WaitForChild('Events')
Events.Purchase.OnServerEvent:Connect(function(Player, Item, Price)
local gear = Item:Clone()
gear.Parent = Player.Backpack
Player.leaderstats.Money.Value = Player.leaderstats.Money.Value - Price
end)