How would i find a folder in replicated storage thats the same name as the players name?

I know usually to get a value youd do

 local Value = player.Value

But from what im understanding i can not use local player inside module scripts so i wanted to create a folder in replicated storage thats the same name as the player and put the value in there instead. Im just not sure how id find the folder and only the folder thats the same name as the player

2 Likes

You can use LocalPlayer in ModuleScripts when the ModuleScripts are required by a LocalScript.
You can use FindFirstChild to find things by string value, or you can use square brackets if you know it exists: parentFolder[playerName]

1 Like

It is required by a local script. Im just confused on how to put local player in the module script. I kept getting errors trying the other day

1 Like

Maybe do like put the modulescript on the ReplicatedFirst to access module from both server and client

1 Like

The thing I can think of logically is you want like there’s a folder in ReplicatedStorage and there are folders for each players in the game and you want to add a value to their folders using ModuleScripts but you are confused on how to get LocalPlayer in ModuleScripts

1 Like

It should just be game.Players.LocalPlayer as always. How did you have it?

1 Like

i had it that way but i but i needed the value in the player.

 local Value = Players.LocalPlayer.Value1

and then at where i needed it i had it as

["Test"] = Value

and i kept getting attempt to index with with Value1

1 Like

You should probably add a parameter to your function in your modulescript named player and return the player, and after accessing it from local script, set the player parameter to local player, then change the name of your folder to player’s name

1 Like

And you’re not requiring the ModuleScript in a regular Script? If the exact error was attempt to index nil with Value1 on that line, then I can’t see any reason why that particular line wouldn’t work.

1 Like

the module script is required in a local script

1 Like

This is the way i had my module script atm and it works. But the value inside the player doesnt change. And even if the player doesnt own the gampass itll still give a true value for the shop to show that specific item

local Players = game:GetService("Players")
local MarketplaceService = game:GetService("MarketplaceService")


local function Even(player)
if MarketplaceService:UserOwnsGamePassAsync(player.UserId,24648574) then
    local Even = player.Even	

    Even.Value = true	
else
	Even.Value = false
end
end




local TowerShop = {
["Test1"] = {
	["Name"] = "Test",
	["ImageAsset"] = "rbxassetid://" ,
	["Price"] = 0,
	["Description"] = "Blank",
	["Event"] = Even,
   }
}

return TowerShop
2 Likes

Dude in the even function, atleast return the value

1 Like

You aren’t assigning a value to [“Event”]

Hmmm…It seems like you want to literally ignore me just because my avatar is bacon, if you think like that, only if you do, then let me tell that this is my alt, my main is @RobloxMastersTeam1, but anyways good luck, I hope you get answers, I won’t post anything because who cares

Im not ignoring you. I was just about to ask where would i put return. Was trying what you said in the beginning but couldnt get it to work. And what do you mean by assigning a value to “Event”? Event should be the value of Even

1 Like

Dude but see, even is a function you are assigning. Also, return is putted at the last of a function. Like do return Even

To get a value from function, just return it, then it would be an actual value instead of a function

So after i do even.value = true or false?

I mean that in the even function, you made a variable called Even, but you forgot to return the Even variable. Just for you to understand what I mean, I said that you need to return a “variable”, but it’s like you returned the value you want to get from a function. Basically, return means like you have a weighing machine, you put something in it to weigh, and it shows the weight i.e the value, so it returns a value

I put the return and it still does the same thing. shows up even tho the Even value in the player is false. But even if i own the gamepass it still shows up false