"Folder" is not a vaild member of Player

wait take my entire code

local gamepassID = 259204857
local gamespass2xID = 259206466
local gamespass5xID = 259207041
local gamespass3xID = 259215442
local Players = game:GetService('Players')
local datastoreservice = game:GetService("DataStoreService")
local remotevent = game.ReplicatedStorage.playeraddedremote

local database = datastoreservice:GetDataStore("data")
local sessiondata = {}

local function Playeradded(plr)
	
	local leaderstats = Instance.new("Folder")
	leaderstats.Name =  "leaderstats"
	
	-- player cash
	local Cash = Instance.new("NumberValue")
	Cash.Name = "Cash"
	Cash.Value = 0
	Cash.Parent = leaderstats
	-- another folder to store button value
	local buttonfolder = Instance.new("Folder")
	buttonfolder.Name = "ButtonsFolder"
	buttonfolder.Parent = plr
	-- for gamepass
	local get2x = game:GetService("MarketplaceService"):UserOwnsGamePassAsync(plr.UserId , gamespass2xID)
	local get3x = game:GetService("MarketplaceService"):UserOwnsGamePassAsync(plr.UserId , gamespass3xID)
	local get5x = game:GetService("MarketplaceService"):UserOwnsGamePassAsync(plr.UserId , gamespass5xID)
	
	-- creates gamepass values
		local pass2x = Instance.new("IntValue")
		pass2x.Name = "Cash2x"
		pass2x.Value = 1
		pass2x.Parent = buttonfolder
	if get2x then
		pass2x.Value = 2
	end
	
		local pass3x = Instance.new("IntValue")
		pass3x.Name = "Cash3x"
		pass3x.Value = 1
	pass3x.Parent = buttonfolder
	if get3x then
		pass3x.Value = 3
	end
	
		local pass5x = Instance.new("IntValue")
		pass5x.Name = "Cash5x"
		pass5x.Value = 1
	pass5x.Parent = buttonfolder
	if get5x then
		pass5x.Value = 5
	end
	
	
	-- for VIP gamepass
	local Gamepass =  game:GetService("MarketplaceService"):UserOwnsGamePassAsync(plr.UserId , gamepassID)
	-- for VIP
		local VIP = Instance.new("BoolValue")
		VIP.Name =  "VIP"
		VIP.Value = false
		VIP.Parent = plr
	
	
	-- when the button is purchased it will chaneg the value coresponding
	local button2 = Instance.new("BoolValue")
		button2.Name = "Button2"
		button2.Value = false
	button2.Parent = buttonfolder
	
	local button3 = Instance.new("BoolValue")
		button3.Name = "Button3"
		button3.Value = false
	button3.Parent = buttonfolder
	
	
	local button5= Instance.new("BoolValue")
		button5.Name ="Button5"
	    button5.Value=false
	button5.Parent=buttonfolder
	
	local button6 = Instance.new("BoolValue")
		button6.Name = "Button6"
		button6.Value = false
	button6.Parent = buttonfolder
	
	
	
	local button8= Instance.new("BoolValue")
		button8.Name ="Button8"
	    button8.Value=false
	button8.Parent=buttonfolder
		
	local button9= Instance.new("BoolValue")
		button9.Name ="Button9"
	    button9.Value=false
	button9.Parent=buttonfolder

	
	local button11 = Instance.new("BoolValue")
		button11.Name = "Button11"
		button11.Value = false
	button11.Parent = buttonfolder
	
	local button12= Instance.new("BoolValue")
		button12.Name ="Button12"
	    button12.Value=false
	button12.Parent=buttonfolder
	

	local button4VIP = Instance.new("BoolValue")
	button4VIP.Name = "Button4VIP"
	button4VIP.Value = false
	button4VIP.Parent = buttonfolder
	
	local button7VIP = Instance.new("BoolValue")
	button7VIP.Name = "Button7VIP"
	button7VIP.Value = false
	button7VIP.Parent = buttonfolder
	
	local button5VIP =  Instance.new("BoolValue")
	button5VIP.Name = "Button5VIP"
	button5VIP.Value = false
	button5VIP.Parent = buttonfolder
	
	local button6VIP =  Instance.new("BoolValue")
	button6VIP.Name = "Button6VIP"
	button6VIP.Value = false
	button6VIP.Parent = buttonfolder
	
	local button8VIP= Instance.new("BoolValue")
		button8VIP.Name ="Button8Vip"
	    button8VIP.Value=false
	button8VIP.Parent=buttonfolder
		
	local button9Vip= Instance.new("BoolValue")
		button9Vip.Name ="Button9Vip"
	    button9Vip.Value=false
	button9Vip.Parent=buttonfolder
		
	local button10vip =  Instance.new("BoolValue")
		button10vip.Name ="Button10Vip"
	    button10vip.Value=false
	button10vip.Parent= buttonfolder 
	
	local button11VIP =  Instance.new("BoolValue")
		button11VIP.Name = "Button11Vip"
		button11VIP.Value = false
	button11VIP.Parent = buttonfolder
	
	local button12VIP= Instance.new("BoolValue")
		button12VIP.Name ="Button12Vip"
	    button12VIP.Value=false
	button12VIP.Parent=buttonfolder
	
	-- Datasave 
	local success = nil
	local playerdata = nil 
	local errorMessage = nil
	local attempt = 1
	repeat
		success, errorMessage = pcall(function()
			 playerdata = database:GetAsync(plr.UserId)
		end)
		attempt += 1
		if not success then
			warn(errorMessage)
			task.wait(3)
		end
	until success or attempt == 5
	
	if success then
		print("Connected to Database!")
		if not playerdata then
			print("Assigning Default Data")
			-- players Data
			playerdata = {
				-- add all the player instance value here in a data
				-- cash value
				["Cash"] = 0,
				-- VIP VALUE
				["VIP"] = false, 
				-- Boost value
				["Get2x"] = 1,
				["Get3x"] =  1,
				["Get5x"] = 1,
				-- button value 
				["Button2"] = false,
				["Button3"] = false,
				["Button4VIP"] = false,
				["Button5"] = false,
				["Button5VIP"] = false,
				["Button6"] = false,
				["Button6VIP"] = false,
				["Button7VIP"] = false,
				["Button8"] = false,
				["Button8VIP"] = false,
				["Button9"] = false,
				["Button9VIP"] = false,
				["Button10VIP"] = false,
				["Button11"] = false,
				["Button11VIP"] = false,
				["Button12"] = false,
				["Button12VIP"] = false
			}
		end
		sessiondata[plr.UserId] = playerdata
	else -- if can't get player data
		warn("Unable to get Data for", plr.Name)
		plr:Kick("Unable to load your Data! Please Try again Shortly!")
		
	end
	
	
	-- for button2 value 
	button2.Value = sessiondata[plr.UserId].Button2
	button2.Changed:Connect(function()
		sessiondata[plr.UserId].Button2 = button2.Value
	end)
	-- for button3 value
	button3.Value = sessiondata[plr.UserId].Button3
	button3.Changed:Connect(function()
		sessiondata[plr.UserId].Button3 = button3.Value
	end)
	-- for button 4vip value 
	button4VIP.Value = sessiondata[plr.UserId].Button4VIP
	button4VIP.Changed:Connect(function()
		sessiondata[plr.UserId].Button4VIP = button4VIP.Value
	end)
	-- for button 5 value 
	button5.Value = sessiondata[plr.UserId].Button5
	button5.Changed:Connect(function()
		sessiondata[plr.UserId].Button5 = button5.Value
	end)
	-- for button 5 vip
	button5VIP.Value = sessiondata[plr.UserId].Button5VIP
	button5VIP.Changed:Connect(function()
		sessiondata[plr.UserId].Button5VIP = button5VIP.Value
	end)
	-- for button 6
	button6.Value = sessiondata[plr.UserId].Button6
	button6.Changed:Connect(function()
		sessiondata[plr.UserId].Button6 = button6.Value
	end)
	-- for button 6 vip 
	button6VIP.Value = sessiondata[plr.UserId].Button6VIP
	button6VIP.Changed:Connect(function()
		sessiondata[plr.UserId].Button6VIP = button6VIP.Value
	end)
	-- for button 7 Vip 
	button7VIP.Value = sessiondata[plr.UserId].Button7VIP
	button7VIP.Changed:Connect(function()
		sessiondata[plr.UserId].Button7VIP = button7VIP.Value
	end)
	-- for button 8
	button8.Value = sessiondata[plr.UserId].Button8
	button8.Changed:Connect(function()
		sessiondata[plr.UserId].Button8 = button8.Value
	end)
	-- for button 8 vip
	button8VIP.Value = sessiondata[plr.UserId].Button8VIP
	button8VIP.Changed:Connect(function()
		sessiondata[plr.UserId].Button8VIP = button8VIP.Value
	end)
	-- for button 9
	button9.Value = sessiondata[plr.UserId].Button9
	button9.Changed:Connect(function()
		sessiondata[plr.UserId].Button9 = button9.Value
	end)
	-- for button 9 vip
	button9Vip.Value = sessiondata[plr.UserId].Button9VIP
	button9Vip.Changed:Connect(function()
		sessiondata[plr.UserId].Button9VIP = button9Vip.Value
	end)
	-- for button 10 vip
	button10vip.Value = sessiondata[plr.UserId].Button10VIP
	button10vip.Changed:Connect(function()
		sessiondata[plr.UserId].Button10VIP = button10vip.Value
	end)
	-- for button 11
	button11.Value = sessiondata[plr.UserId].Button11
	button11.Changed:Connect(function()
		sessiondata[plr.UserId].Button11 = button11.Value
	end)
	-- for button 11 vip
	button11VIP.Value = sessiondata[plr.UserId].Button11VIP
	button11VIP.Changed:Connect(function()
		sessiondata[plr.UserId].Button11VIP = button11VIP.Value
	end)
	-- for button 12
		button12.Value = sessiondata[plr.UserId].Button12
	button12.Changed:Connect(function()
		sessiondata[plr.UserId].Button12 = button12.Value
	end)
	-- for button 12 vip 
	button12VIP.Value = sessiondata[plr.UserId].Button12VIP
	button12VIP.Changed:Connect(function()
		sessiondata[plr.UserId].Button12VIP = button12VIP.Value
	end)
	buttonfolder.Parent = plr
	-- for 2x VALUE 
	pass2x.Value = sessiondata[plr.UserId].Get2x
	pass2x.Changed:Connect(function()
		sessiondata[plr.UserId].Get2x = pass2x.Value
	end)
	-- for 3x value 
	pass3x.Value = sessiondata[plr.UserId].Get3x
	pass3x.Changed:Connect(function()
		sessiondata[plr.UserId].Get3x = pass3x.Value
	end)
	-- for 5x value 
	pass5x.Value = sessiondata[plr.UserId].Get5x
	pass5x.Changed:Connect(function()
		sessiondata[plr.UserId].Get5x = pass5x.Value
	end)
	-- for VIP value 
	VIP.Value = sessiondata[plr.UserId].VIP
	VIP.Changed:Connect(function()
		sessiondata[plr.UserId].VIP = VIP.Value
	end)
	
	-- for cash value 
	Cash.Value = sessiondata[plr.UserId].Cash
	Cash.Changed:Connect(function()
		sessiondata[plr.UserId].Cash = Cash.Value
	end)
	leaderstats.Parent = plr
	remotevent:FireClient(plr, true)	
end


game.Players.PlayerAdded:Connect(Playeradded)

function playerleaving(player)
	-- stores the Data if the player is leaving
	if sessiondata[player.UserId] then
		local success = nil
		local errorMsg = nil
		local attempt = 1
		repeat
		success, errorMsg = pcall(function()
			database:SetAsync(player.UserId, sessiondata[player.UserId])
			end)
			attempt += 1
			if not success then
				warn(errorMsg)
				task.wait(3)
			end
		until success or attempt == 5
		
		if success then
			print("Data Saved!", player.Name)
		else
			warn("Unable to save Data!" , player.Name)
		end
	end
end
game:BindToClose(function()
	for Index, Player in Players:GetPlayers() do -- Add Players service: 
		pcall(function() 
			playerleaving(Player)
		end)
	end
end)
	
game.Players.PlayerRemoving:Connect(playerleaving)	

	
	


Is there a reason that the indentation is like that-?

Considering the script does it’s job, I think you just need to delay it for a little bit.

task.wait(5) --sanity check, I think 5 seconds is enough, you can put this under the print(buttonfolder)
local button = workspace.Buttonsim.Buttonsfolder
local function buttonvalue(player)

hmm any other errors or things that i might have missed out?

Not exactly sure, I think you should try delaying the script from running for a few seconds while stuff loads in and report back on what results you get.

hmm the code might have done it’s job but the result is weird,

it should check the value and if it is true then delete the blue thing in the button but it didn’t work out!

Another possible solution is having a bindable event called like playerSetup or something along those lines which fires at the end of the player setup script and then is listened to from the other script.

1 Like

bruh those things might go above my head man

I was hesitant to say that but yeah since that requires extra scripting which can be sometimes a pain.

I believe it would be the ideal way

I can give you step by step instructions if you would like:

  1. Insert a BindableEvent called “FinishedPlayerSetup”
  2. Reference the event in the PlayerLoading script
  3. In the player loading script insert this line at this point
leaderstats.Parent = plr
FinishedPlayerSetup:Fire(plr) -- Insert this line here at line 331
remotevent:FireClient(plr, true)	
  1. In the ButtonScript reference the same event
  2. At the bottom of the ButtonScript insert this in replacement of the player added event
FinishedPlayerSetup.Event:Connect(buttonvalue)
1 Like

You should try putting print("I did a thing!") under if buttonfolder then to see if it at least prints anything.

it is running because button2 is in the if statement just the button2 value is the problem

Oh my bad I suppose I misunderstood that.

Looking at the script again it should work, don’t think anythings wrong with it so ill keep looking for errors and report back.

Uhh well it worked but it worked only for the server but i want it for local player!

Can you walk through the block? or is there collision?

Scratching my head with this already since it appears to be fine.

you can walk thorugh the block!

when the event is receivied it will turn of the transperency and can collide so the player can go throught it!

The issue here is the script is firing this towards a local script.

The local script will never see since a normal script is firing it.

You’d have to use remote event instead of a bindable event.

oh wait is the button script a local script or a script?

I realized it’s local, unless you want everyone to be affected on the server via the button script.

Well it should be local anyways.