So I am currently making a system for when a player clicks a GUI button they purchase an item with their leaderstats money. The way I am doing this is I am firing a remote event. Here is the script for when they click on the GUI.
local purchaseOne = script.Parent.PurchaseOne
local item = nil
local price = 50
local player = game:GetService("Players").LocalPlayer
local rs = game:GetService("ReplicatedStorage")
local re = rs:WaitForChild("EquipRe")
local function purchaseLevelOne()
item = "LevelOne"
price = 50
end
local function buyIt()
local Coins = player.leaderstats:FindFirstChild("Coins")
if Coins.Value >= price then
Coins.Value = Coins.Value - price
re:FireServer(item)
end
end
purchaseOne.Activated:Connect(purchaseLevelOne)
purchaseOne.Activated:Connect(buyIt)
After the player clicks on the button it fires the remote event and sends the info over to this next script. This first script works fine and sends all the info correctly. Its just on this second script I get an error Argument 1 missing or nil on line 7 of this script below.
local rs = game:GetService("ReplicatedStorage")
local re = rs:WaitForChild("EquipRe")
local function giveTool(player, item)
print("Test")
local tools = rs:WaitForChild("tools")
local tool = tools:FindFirstChild(item):Clone()
tool.Parent = player.Backpack
end
re.OnServerEvent:Connect(giveTool)
I am not sure why it says this because I have a folder within replicated storage named tools with a tool inside.
