So I tried making a shop script this time, and it works. The problem is the last 2 items (the Green Sword and Rocket Launcher) is swapped on purchase, meaning when I buy the Green Sword I got a Rocket Launcher and vice versa. And yes, I have FE enabled. If you want to see the explorer I have put it below the scripts
These are the buy scripts:
Local Script:
local buybutton = script.Parent.BuyButton
local id = script.Parent.Parent.ItemPressedValue
local items = script.Parent.Parent.Items:GetChildren()
local player = game.Players.LocalPlayer
buybutton.MouseButton1Click:Connect(function()
player.leaderstats.Money.Value = player.leaderstats.Money.Value - items[id.Value].Price.Value
game:GetService("ReplicatedStorage").Events.BoughtTool:FireServer(id.Value)
end)
ServerScript on ServerScriptService
game:GetService("ReplicatedStorage").Events.BoughtTool.OnServerEvent:Connect(function(player, itemId)
local items = game:GetService("ReplicatedStorage").Tools:GetChildren()
print(player.Name.. "has bought an item of id: ".. itemId)
local clone = items[itemId]:Clone()
clone.Parent = game:GetService("Players")[player.Name].Backpack
end)
The Shop Gui: https://prnt.sc/jpuitl the buying script is the local script
The Item buttons have the name, picture id, price, and item tag on them
The Items: https://prnt.sc/jpui24
If you need more picture I will gladly provide :)

1 comment
The printing id is correct but it gave me the wrong item :)