Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Camera Subject not Changing with Local Script. How to fix?

So I've been trying in every way possible but I just can't figure out why my script isn't working. I've managed to get rid of any errors so no errors. I basically wanna make a gui that changes the character by changing the local player's character to some other model, I've managed to do that but now I'm just struggling to figure out how to change the camera subject from the humanoid without any body parts to the actual new character assigned.

local ReplicatedStorage = script.Parent.Parent.Parent.Parent.Functions
local createPartEvent = ReplicatedStorage:WaitForChild("bigheadyellow")
local CurrentCamera = workspace.CurrentCamera
local plr = game.Players.LocalPlayer
local pln = script.Parent.Parent.Parent.Parent.Parent.Parent.Name

function onClicked()
	createPartEvent:FireServer()
	wait(1)
	CurrentCamera.CameraType = "Scriptable"
	CurrentCamera.CameraSubject = plr.Character.Humanoid
end
script.Parent.MouseButton1Down:connect(onClicked)

2 comments

0

using localscript for this script

0

the script seems to work if I make the camerasubject something like game.Workspace.target

2 answers

The reason why you can't change the camerasubject is because you are setting the cameratype to Scriptable, which basically makes it so that the main camerascript stops controlling the camera.

If you want it so that the camera is static and the camera is set somewhere.

local ReplicatedStorage = script.Parent.Parent.Parent.Parent.Functions
local createPartEvent = ReplicatedStorage:WaitForChild("bigheadyellow")
local CurrentCamera = workspace.CurrentCamera
local plr = game.Players.LocalPlayer
local pln = script.Parent.Parent.Parent.Parent.Parent.Parent.Name

function onClicked()
    createPartEvent:FireServer()
    wait(1)
    CurrentCamera.CameraType = "Scriptable"
    --set its location with a cframe
    CurrentCamera.CFrame=CFrame.new()
end
script.Parent.MouseButton1Down:connect(onClicked)

Or if you want to reset the camera so that it goes back to normal you have to set the cameratype to Custom, which the to default value that most games are set to.

local ReplicatedStorage = script.Parent.Parent.Parent.Parent.Functions
local createPartEvent = ReplicatedStorage:WaitForChild("bigheadyellow")
local CurrentCamera = workspace.CurrentCamera
local plr = game.Players.LocalPlayer
local pln = script.Parent.Parent.Parent.Parent.Parent.Parent.Name

function onClicked()
    createPartEvent:FireServer()
    wait(1)
    CurrentCamera.CameraType = "Custom"
    CurrentCamera.CameraSubject = plr.Character.Humanoid
end
script.Parent.MouseButton1Down:connect(onClicked)

1 comment

0

Seems none of the answers you gave are working :( thank you for explaining some of it though

This discussion is preserved as it was. New answers, comments, and votes are closed.