[HELP] carwash script

I am trying to get this carwash script to work but everytime I try to boot it in my server I get this error:


I just would like to know what I am doing wrong. I keep trying to correct it but I cannot figure it out. can someone help me please?

Below is the code I use for my script.

--Settings--

enableprice = false -- true = carwash is paid, false = carwash is free

price = 100 -- you may edit this to your liking. if "enableprice = false" ignore this one

--DO-NOT-EDIT-BELLOW-THIS-LINE--

RegisterServerEvent('carwash:checkmoney')
AddEventHandler('carwash:checkmoney', function()
	TriggerEvent('es:getPlayerFromId', source, function(player)
		if(enableprice == true) then
			if(player:money >= price) then
				player:removeMoney((price))
				TriggerClientEvent('carwash:success', source, price)
			else
				moneyleft = price - player:money
				TriggerClientEvent('carwash:notenoughmoney', source, moneyleft)
			end
		else
			TriggerClientEvent('carwash:free', source)
		end
	end)
end)

Here use the code that works for me.

--Settings--
ESX = nil

enableprice = true -- true = carwash is paid, false = carwash is free

price = 500 -- you may edit this to your liking. if "enableprice = false" ignore this one

--DO-NOT-EDIT-BELLOW-THIS-LINE--
TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end)

RegisterServerEvent('carwash:checkmoney')
AddEventHandler('carwash:checkmoney', function()
	local mysource = source
	local xPlayer = ESX.GetPlayerFromId(source)		
		if(enableprice == true) then
			if(xPlayer.getMoney() >= price) then
				xPlayer.removeMoney((price))
				TriggerClientEvent('carwash:success', mysource, price)
				
			else
				moneyleft = price - xPlayer.getMoney()
				TriggerClientEvent('carwash:notenoughmoney', mysource, moneyleft)
			end
		else
			TriggerClientEvent('carwash:free', mysource)
		end
end)

^ was Server lua file. this is the client file

--DO-NOT-EDIT-BELLOW-THIS-LINE--

Key = 201 -- ENTER

vehicleWashStation = {
	{26.5906,  -1392.0261,  27.3634},
	{167.1034,  -1719.4704,  27.2916},
	{-74.5693,  6427.8715,  29.4400},
	{-699.6325,  -932.7043,  17.0139}
}


Citizen.CreateThread(function ()
	Citizen.Wait(0)
	for i = 1, #vehicleWashStation do
		garageCoords = vehicleWashStation[i]
		stationBlip = AddBlipForCoord(garageCoords[1], garageCoords[2], garageCoords[3])
		SetBlipSprite(stationBlip, 100) -- 100 = carwash
		SetBlipAsShortRange(stationBlip, true)
	end
    return
end)

function DrawSpecialText(m_text, showtime)
	SetTextEntry_2("STRING")
	AddTextComponentString(m_text)
	DrawSubtitleTimed(showtime, 1)
end

Citizen.CreateThread(function ()
	while true do
		Citizen.Wait(0)
		if IsPedSittingInAnyVehicle(GetPlayerPed(-1)) then 
			for i = 1, #vehicleWashStation do
				garageCoords2 = vehicleWashStation[i]
				DrawMarker(1, garageCoords2[1], garageCoords2[2], garageCoords2[3], 0, 0, 0, 0, 0, 0, 5.0, 5.0, 2.0, 0, 157, 0, 155, 0, 0, 2, 0, 0, 0, 0)
				if GetDistanceBetweenCoords(GetEntityCoords(GetPlayerPed(-1)), garageCoords2[1], garageCoords2[2], garageCoords2[3], true ) < 5 then
					DrawSpecialText("Press enter to wash the car")
					if(IsControlJustPressed(1, Key)) then
						TriggerServerEvent('carwash:checkmoney')
					end
				end
			end
		end
	end
end)

RegisterNetEvent('carwash:success')
AddEventHandler('carwash:success', function(price)
	SetVehicleDirtLevel(GetVehiclePedIsIn(GetPlayerPed(-1),  false),  0.0000000001)
	SetVehicleUndriveable(GetVehiclePedIsUsing(GetPlayerPed(-1)), false)
	TriggerEvent('chatMessage', 'carwash', {255, 0, 0}, "Your car has been washed for " .. price .. "$")
	--TriggerEvent('chatMessage', 'Bilvasken', {255, 0, 0}, "Din bil er blevet vasket for " .. price .. "kr") -- danish
	DrawSpecialText(msg, 5000)
	Wait(5000)
end)

RegisterNetEvent('carwash:notenoughmoney')
AddEventHandler('carwash:notenoughmoney', function(moneyleft)
--	TriggerEvent('chatMessage', 'Bilvasken', {255, 0, 0}, "Du har ikke penge nok, du mangler " .. moneyleft .. "kr") -- danish
	TriggerEvent('chatMessage', 'carwash', {255, 0, 0}, "You do not have enough money you're missing " .. moneyleft .. "$") 
	DrawSpecialText(msg, 5000)
	Wait(5000)
end)

RegisterNetEvent('carwash:free')
AddEventHandler('carwash:free', function()
	SetVehicleDirtLevel(GetVehiclePedIsUsing(GetPlayerPed(-1)))
	SetVehicleUndriveable(GetVehiclePedIsUsing(GetPlayerPed(-1)), false)
	-- TriggerEvent('chatMessage', 'carwash', {255, 0, 0}, "bilvasken er gratis" .. price .. "kr")  -- danish
	TriggerEvent('chatMessage', 'carwash', {255, 0, 0}, "carwash its free" .. price .. "$") 
	DrawSpecialText(msg, 5000)
	Wait(5000)
end)

And in the __resource it should be

client_script 'carwash_client.lua'
server_script 'carwash_server.lua'

Thank you that helped out a lot!!!

1 Like