Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

i don't know how to get a certain folder?

Asked by 3 years ago

i made a script that makes a folder for each player, so that server scripts can get player data

but i am having trouble with what to add next ( i need to get the player id of who triggered the proximity prompt but i need to get the name first)

it goes player_data > player name > any player propertey

local DSS = game:GetService("DataStoreService")
local cars_store = DSS:GetDataStore("player_cars")
local SS = game:GetService("ServerStorage")
local dealer = game.Workspace.dealer

function spawn_car(player)
    local player_id = game.Workspace.player_data -- idk what to add next

    cars_store:SetAsync()
end

dealer.head.ProximityPrompt.Triggered:Connect(spawn_car)

if you need to know more, here is the folder maker script

local player = script.Parent.Parent
local new_folder = Instance.new("Folder")

new_folder.Name = player.Name
new_folder.Parent = game.Workspace.player_data


---------------


local user_id = Instance.new("NumberValue", new_folder)


---------------


user_id.Name = "user_id"
user_id.Value = player.UserId

1 answer

Log in to vote
0
Answered by 3 years ago

You're passing a player in the spawn_car function, there is no need to create folders to store it.

function spawn_car(player)
    local player_id = player.UserId -- Here.
    cars_store:SetAsync()
end
Ad

Answer this question