I am build a Menu for a HOLO. I have the cameras working and so is the GUI(But the button is not working because of the PlayerScripts)

My attempt was to remove the PlayerScripts(CameraScript and ControlScript) then when I press the button, the PlayerScript that I have a copy of will be ":clone()" into the Player's PlayerScript folder.

The problem it is wont delete nor add the script because of the following: "attempt to index global 'p' (a nil value)" on any line that uses... "p".


	--//Myaxp

game.Players.ChildAdded:connect(function(p) -- Another script loads the PlayerScripts into the player through a button.
	--a = game:GetService("Players").LocalPlayer
	wait(1)
	--a = game:GetService("Players")
	p.LocalPlayer.PlayerScript.CameraScript:Destroy()
	p.LocalPlayer.PlayerScript.ControlScript:Destroy()
end)

	--//End

BTW, "Line 4" had PlayerAdded but seemed to have no effect, neither does ChildAdded. So I don't know what I did wrong.

Can someone figure out the problem?

--//Myaxp

6 comments

0

Is it local script?

0

It was... But it had no effect. It is also why I had Child Added!

0

p is a Player, not "Players" service. LocalPlayer is useless. And it must be PlayerScripts, not PlayerScript

0

... Oh. Did not noticed for the 20 minutes I stared at the code... I will try it.

0

However loading up the explorer in "test" mode, There is no StarterScripts... Is this normal??????

0

Nvm I sorted it.