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

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

Asked by 5 years ago

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)
0
using localscript for this script WyattagumsBackUp 5 — 5y
0
the script seems to work if I make the camerasubject something like game.Workspace.target WyattagumsBackUp 5 — 5y

2 answers

Log in to vote
0
Answered by
DanzLua 2879 Moderation Voter Community Moderator
5 years ago

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)
0
Seems none of the answers you gave are working :( thank you for explaining some of it though WyattagumsBackUp 5 — 5y
Ad
Log in to vote
0
Answered by 5 years ago

made a fix camera button

Answer this question