Created
June 4, 2025 15:18
-
-
Save MajorTal/7cf0958477f5aaec79c315d9b7f69cbb to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local ReplicatedStorage = game:GetService("ReplicatedStorage") | |
local ServerStorage = game:GetService("ServerStorage") | |
local ShopItems = require(ServerStorage.ShopItems) | |
local buyItemEvent = ReplicatedStorage:WaitForChild("BuyItemEvent") | |
buyItemEvent.OnServerEvent:Connect(function(player, itemType) | |
local itemDef = ShopItems[itemType] | |
if not itemDef then | |
warn("Unknown item:", itemType) | |
return | |
end | |
local cash = player.leaderstats.Cash | |
if cash.Value >= itemDef.Price then | |
cash.Value -= itemDef.Price | |
-- Give generic placement tool set to this item | |
local toolClone = ServerStorage.PlacementTool:Clone() | |
toolClone.ItemType.Value = itemType | |
toolClone.Parent = player.Backpack | |
print(player.Name .. " bought item:", itemType) | |
else | |
warn("Not enough cash for item:", itemType) | |
end | |
end) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment