I made this shop system and whenever the player buys the item, it takes away their Cash but the tool doesn’t get put in the players backpack
There isn’t any errors in the output or anything
Please help!
Here’s the lua
local serverStorage = game:GetService("ServerStorage")
local buyRemote = game:GetService("ReplicatedStorage").ShopRemotes.BuyItem
local itemCosts = {
AK74U = 3500,
BANDAGE = 200,
UZI = 2000,
}
buyRemote.OnServerEvent:Connect(function(player,item)
local playerMoney = player.leaderstats.Cash
if playerMoney.Value < itemCosts[item] then return end
playerMoney.Value -= itemCosts[item]
local toolToGive = serverStorage.Tools.FindFirstChild(item)
toolToGive.Parent = player.Backpack
end)
Kaid3n22
(Kaiden)
#2
you need to use colons for FindFirstChild.
local serverStorage = game:GetService("ServerStorage")
local buyRemote = game:GetService("ReplicatedStorage").ShopRemotes.BuyItem
local itemCosts = {
AK74U = 3500,
BANDAGE = 200,
UZI = 2000,
}
buyRemote.OnServerEvent:Connect(function(player,item)
local playerMoney = player.leaderstats.Cash
if playerMoney.Value < itemCosts[item] then return end
playerMoney.Value -= itemCosts[item]
local toolToGive = serverStorage.Tools:FindFirstChild(item)
toolToGive.Parent = player.Backpack
end)
with a period, it would be trying to find an instance with the name of “FindFirstChild” under the tool.
1 Like
ohh must have been a spelling error, thank you so much for the help man!