I have two CameraScripts. One is for locked third person and the other is the default one. I would like to be able to switch them while playing.
Changing scripts manually (dragging and dropping) work without problems.
I tried creating a LocalScript in StarterPack with the following code. CameraScript is in LocalScript.
local cameraScript = script:WaitForChild("CameraScript")
local starterPlayer = game:GetService("StarterPlayer")
local starterPlayerScripts = starterPlayer:FindFirstChild("StarterPlayerScripts")
local existing = starterPlayerScripts:FindFirstChild("CameraScript")
if existing then
existing:Destroy()
end
local new = cameraScript:clone()
new.Parent = starterPlayerScripts
new.Disabled = false
The script runs fully without errors but it doesn't seem to be doing anything.
So I need to remove and replace the script that is located in Players.Player1.PlayerScripts.CameraScript
