I made a car Purchase system in my game, the script is in ServerScriptService. Im getting this error on the first line: Argument 1 missing or nil - Server - PurchaseScript:4
I dont know how to fix this, i appreciate if anyone could help me fix it.
local player = game.Players:findFirstChild()
local price = 15000 --Change to price of vehicle
local CarName = "Beige Dune Buggy" --Change to vehicle name
--Do not edit past this
local player = script.Parent.Parent.Parent.Parent.Parent
local Money = player.leaderstats.Money
script.Parent.Parent.Parent.Name = CarName
local BuyTitle = script.Parent.Parent.TextLabel
BuyTitle.Text = "Would you like to buy " .. CarName .. " for " .. price --This automaticly changes the GUI to show the name of the vehicle and the price!
script.Parent.MouseButton1Click:Connect(function()
if Money.Value >= price and player[CarName][CarName].Value == 0 then--If the player has enough money and does not own the vehicle
Money.Value = Money.Value - price--Takes the money
player[CarName][CarName].Value = 2
wait()
script.Parent.Parent.Parent.Enabled = false
elseif Money.Value <= price and player[CarName][CarName].Value == 0 then
BuyTitle.TextColor3 = Color3.new(1, 0, 0.0156863)
wait(0.3)
BuyTitle.TextColor3 = Color3.fromRGB(150, 150, 150)
--BuyTitle.TextColor3 = Color3.new(150, 150, 150)
end
end)