Code Prints (Nil) when trying to access player folders

  1. What do you want to achieve?
    I’ll I’m trying to do is access the players Folders known as (CarsOwnedFolder) not to edit, but only to be used to check if player owns said item as what the code will do is this.

If the value is inside the folder (CarNamed) is equal to the (CarNameValue) inside a button then the player owns the car

  1. What is the issue? Include
    So close to getting this working, it’s just (trouble-sum) of trying to access the players folder using a normal script.

You might say, why aren’t you using a (Local-Script), that’s because my script works fine as it displays the info about the cars name, it’s price, and image. So if I switch it to a (Local-Script), it just leaves everything blank and errors out certain parts of the code.

  1. What solutions have you tried so far?
    None of the other post actually helped as they have different needs in different situation.
local CarNameValue = script.Parent.Parent.Parent.Parent.Parent.Vehicle_Info.Side_Info
local CarNameValue2 = script.Parent.Parent.Parent.Parent.Parent.Vehicle_Info

local Vehicle_Info_Values_Folder = script.Parent.Parent.Vehicle_Info_Values_Folder
local VehicleSpawnName = script.Parent.Vehicle_Spawn_Name
local FakeVehicleName = script.Parent.Fake_Vehicle_Name
local BBN = Vehicle_Info_Values_Folder.Build_By
local Built_by = CarNameValue.Built_By
local CarYear = Vehicle_Info_Values_Folder.Year
local CarOrigin = Vehicle_Info_Values_Folder.Origin
local CarClass = Vehicle_Info_Values_Folder.Class
local CarColor = Vehicle_Info_Values_Folder.Car_Color
local Vehicle_Image = script.Parent.Parent.Car_Image

local HasVariant = script.Parent.HasVariant
local HasTrailer = script.Parent.HasTrailer
local VAR_Text = CarNameValue2.Bottom.Variant_Check
local TRLR_Text = CarNameValue2.Bottom.Trailer_Check

local DVF = script.Parent.Parent.Parent.Parent.Parent
--local CarMoneyValue = game.ServerStorage.Cars:FindFirstChild(VehicleSpawnName.Value):FindFirstChild("PriceLineValue")

--Buy Car info
local BuyInfo = script.Parent.Parent.Parent.Parent.Parent.Vehicle_Info.Buy_Info
local FindCar = game.ServerStorage.Cars
local Naming = script.Parent.Vehicle_Spawn_Name
local Goal = FindCar:FindFirstChild(Naming.Value)


script.Parent.MouseButton1Click:Connect(function(Plr)
	local CarsOwnedFolder = Plr:FindFirstChild("CarsOwnedFolder")
	print(CarsOwnedFolder)--Right here if your reading this on the forums <<<<<<<<
	if Naming.Value == CarsOwnedFolder then--Need to buy the car
		CarNameValue.BuyCars_Button.Visible = true
		CarNameValue.Parent.Buy_Info.BuyIt.Visible = true
		CarNameValue.Parent.Buy_Info.DontBuy.Visible = true
		CarNameValue.Parent.Buy_Info.TextLabel.Visible = true
		CarNameValue.Parent.Buy_Info.OwnedCar.Visible = false
		CarNameValue.Spawn_Button.Visible = false
	else--You own the car
		CarNameValue.BuyCars_Button.Visible = false
		CarNameValue.Parent.Buy_Info.BuyIt.Visible = false
		CarNameValue.Parent.Buy_Info.DontBuy.Visible = false
		CarNameValue.Parent.Buy_Info.TextLabel.Visible = false
		CarNameValue.Parent.Buy_Info.OwnedCar.Visible = true
		CarNameValue.Spawn_Button.Visible = true
	end
	
	BuyInfo.InfoFrame.CarText.Text = ("Car: "..script.Parent.Fake_Vehicle_Name.Value)
	BuyInfo.InfoFrame.PriceText.Text = ("Price: $"..Goal:FindFirstChild("PriceLineValue").Value)
	BuyInfo.InfoFrame.YearText.Text = ("Year: "..script.Parent.Parent.Vehicle_Info_Values_Folder.Year.Value)
	BuyInfo.BuyIt.BuyCarsScript.PriceTagValue.Value = Goal:FindFirstChild("PriceLineValue").Value
	BuyInfo.BuyIt.BuyCarsScript.CarNameValue.Value = Goal.Name
	BuyInfo.Parent.Side_Info.Price_Text.Text = ("Price: $"..Goal:FindFirstChild("PriceLineValue").Value)
	
	
	
	CarNameValue.Spawn_Button.Spawn_Car_Name.Value = (VehicleSpawnName.Value)
	CarNameValue.CarName_Text.Text = (FakeVehicleName.Value)
	CarNameValue.Vehicle_Image.Image = (Vehicle_Image.Image)
	Built_by.Text = ("Built By: "..BBN.Value)
	CarNameValue.Built_By.NamesValue.Value = (BBN.Value)
	CarNameValue2.Bottom.Year_Label.Text = ("Year: "..CarYear.Value)
	CarNameValue2.Bottom.Origin_Label.Text = ("Origin: "..CarOrigin.Value)
	CarNameValue2.Bottom.Class_Label.Text = ("Class: "..CarClass.Value)
	CarNameValue2.Bottom.Color_Label.Text = ("Color: "..CarColor.Value.Name)
	if HasVariant.Value == true then
		VAR_Text.Text = "VAR: Yes"
	else
		VAR_Text.Text = "VAR: No"
	end
	if HasTrailer.Value == true then
		TRLR_Text.Text = "TRLR: Yes"
	else
		TRLR_Text.Text = "TRLR: No"
	end
	if DVF:FindFirstChild("DifferentVersions_Frame") then
		DVF.DifferentVersions_Frame.CloseButton.OG_VehicleName.Value = VehicleSpawnName.Value
	end
end)

Do not write entire scripts or design entire systems.

I wonder if the folder is made on the client and not replicated to the server. Also watch out that a bad user could modify the contents (if it is made client side) and get access to any car.

Yeah, however this is quite a unique way of doing so, instead of using BoolenValues because exploiter can easily change the value to true making them own the car. It uses a StringValue to check if the player owns that car.

If a StringValue is in the folder named after the car, then it checks with the cars name and if that matches with the Values name. Then it I’ll work that way.

Interesting, I’m no expert at Roblox security but I’d still be cautious about anything that originates from client side. That being said, I’m guessing that the client/server difference is what’s causing your issues, so it may have to be changed regardless.

How do you create the folder exactly? I dont see it creating on the script

That has basically 0 impact on the exploitability. The only way to prevent exploiting is to add sanity checks for all remote events and just in general on the server side.
Exploiters have full control over the client and all local scripts.

here this is how:

I see what you mean by that, but no what I mean by unique way is like this.

In a different script for where you buy your cars from, I basically create a new (StringValue) into the players (CarsOwnedFolder) anytime they buy any car, and you can’t do anything with the (StringValue) as all it contains is the Cars Name on the (StringValue).

The idea being the game will know if you own any cars or not is to check if you have that (StringValue), and if you do you get to keep your Cars/Vehicles. Otherwise if you were to delete them, well you would lose your car in this case.

And then to make data saves for every single (StringValue) you have (Or in this case a table).

here:

1 Like

Exploiters can create StringValues on the client, parent them to that folder, and name them to the corresponding car.

makes sense, thanks for that info.

1 Like