PlayerAdded not working in local script

yo wsg, his script ain workin, i been done did tried everythang^ and it still bein green, help me out

game.Players.PlayerAdded:Connect(function(PlayerAdded)
	wait()
for i,v in pairs(plr:WaitForChild("ToolFolder"):GetChildren()) do
	wait()
	print("first loadup")
	eventcount:FireServer(plr)
		local btn = tb:Clone()
		btn.Text = v.Name
	    btn.Name = v.Name
	btn.Parent = game.ReplicatedStorage:WaitForChild("CStorage"):WaitForChild(plr.Name..'_CStorage')
	print("got them stats in the cstorage")
	end
	end)
1 Like

It’s probably not working since by the time the localscript runs, your player has been already added, I don’t think you need it in a PlayerAdded for that, maybe try to change it up for a server script?

Also if plr is your player instance, remove it, it is given automatically

da thing is is that i need it to be local, and i need this to only run one time cuz otherwise itll duplicate

Then I don’t think you need it in a PlayerAdded, you can just put it out of the event and put the localscript soemwhere where it’ll run once, such as StarterPlayerScripts

1 Like