Hello everyone I am trying to add it so that only specific swords need gems to buy them and a few gems not just one. This is my script before adding gems:
local RS = game:GetService("ReplicatedStorage") --I defined the replicated storage here
RS.BuyItem.OnServerEvent:Connect(function(player, price, toolName, button) --When the event fire, do the following commands:
if(not player.Backpack:FindFirstChild(toolName) and not player.Character:FindFirstChild(toolName)) then --If the player does not have the tool
if(player.leaderstats.Gold.Value >= price) then --And if he has more or the same cash than the price
player.leaderstats.Gold.Value = player.leaderstats.Gold.Value - price --Decrease his cash amount by the price
local item = RS.ShopItems[toolName]:Clone() --Clone the tool
item.Parent = player.Backpack --Put it in the player's backpack
button.BackgroundColor3 = Color3.fromRGB(255, 0, 0) --Set the button's color to red
button.Text = "Bought!" --Set the button's text to "Bought!"
wait(1) --Wait one second
button.BackgroundColor3 = Color3.fromRGB(85, 170, 0) --Set the color back to green
button.Text = "Buy" --Change the text to "Buy"
end
end
end)