Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Not destorying camera scripts in player?

Asked by
FiredDusk 1466 Moderation Voter
8 years ago
game.Players.Player.PlayerScript:Destroy()

3 answers

Log in to vote
1
Answered by 8 years ago

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()
0
It says cameraScript is unkown global FiredDusk 1466 — 8y
0
Did you put it in the player in a localscript because I tried before awnsering and it were working XToonLinkX123 580 — 8y
Ad
Log in to vote
0
Answered by
4Bros 550 Moderation Voter
8 years ago

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
0
It does not destroy them. FiredDusk 1466 — 8y
Log in to vote
0
Answered by 8 years ago

make sure the script is a LocalScript and place it in StarterGui or StarterPack

 game.Players.LocalPlayer.PlayerScript:remove()
0
use `Destroy`, `remove` is deprecated:) XToonLinkX123 580 — 8y

Answer this question