game.Players.Player.PlayerScript:Destroy()
COMMUNITY QUESTION
Not destorying camera scripts in player?
3 answers
Put it in a local script in the player, I don't know if you want only delete playerScript or all of the scripts
If you only want to destroy the camerascript
local player = game.Players.LocalPlayer
local playerScripts = player:WaitForChild("PlayerScripts")
local cameraScript = playerScripts:WaitForChild("CameraScripts")
cameraScript:Destroy()
if you want to destroy all scripts in PlayerScript, you need to get all children from the playerScript like this
local player = game.Players.LocalPlayer
local playerScripts = player:WaitForChild("PlayerScripts")
for _, script in next, playerScripts:GetChildren() do
script:Destroy()
end
cameraScript:Destroy()
If you want to destroy the camera script in the player, then you should use WaitForChild on the playerscripts object and then use it again for the camerascript in case those objects haven't been created within the player yet.
local players = game:GetService'Players'
local playerscripts = players["playername"]:WaitForChild'PlayerScripts' -- Put the player's name where playername is
local camerascript = playerscripts:WaitForChild'CameraScript' -- Wait for the camerascript
camerascript:Destroy() -- Destroy it
1 comment
0
It does not destroy them.
make sure the script is a LocalScript and place it in StarterGui or StarterPack
game.Players.LocalPlayer.PlayerScript:remove()
1 comment
0
use Destroy, remove is deprecated:)
This discussion is preserved as it was. New answers, comments, and votes are closed.

2 comments
It says cameraScript is unkown global
Did you put it in the player in a localscript because I tried before awnsering and it were working