So, I’m trying to use this script to update the player’s camera because the character is updated. It doesn’t work.
Scripts
Camera Script (Local)
local player = game:GetService("Players").LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local camera = game.Workspace.CurrentCamera -- always use CurrentCamera to reference the camera
local tool = script.Parent
tool.MouseButton1Click:Connect(function()
if workspace.CurrentCamera and player.Character then
local humanoid = player.Character:FindFirstChildOfClass("Humanoid")
if humanoid then
workspace.CurrentCamera.CameraSubject = humanoid
end
end
end)
The camera is being set before the morph is set due to latency, you could possibly do a remotefunction which will yield until you return and then the camera can be set.
I’ve updated the code and it still doesn’t seem to work.
Local Script
local player = game:GetService("Players").LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local camera = game.Workspace.CurrentCamera -- always use CurrentCamera to reference the camera
local tool = script.Parent
tool.MouseButton1Click:Connect(function()
game.ReplicatedStorage.RalseiCamFunction:InvokeServer()
if workspace.CurrentCamera and player.Character then
local humanoid = player.Character:FindFirstChildOfClass("Humanoid")
if humanoid then
workspace.CurrentCamera.CameraSubject = humanoid
end
end
end)
game.ReplicatedStorage.RalseiCamFunction.OnClientInvoke:Connect(function()
game.ReplicatedStorage.RalseiCamFunction:InvokeServer()
end)
Server Script
script.Parent.MouseButton1Click:Connect(function()
finished = false
local plr = script.Parent.Parent.Parent.Parent.Parent
print(plr.Name .. " morph to ralsei yayaya")
game.Lighting.Ralsei.HumanoidRootPart.CFrame = plr.Character.HumanoidRootPart.CFrame
local clone = game.Lighting.Ralsei:Clone()
clone.Parent = game.Workspace
clone.Name = "Ralsei (".. plr.Name .. ")"
plr.Character = clone
end)
game.ReplicatedStorage.RalseiCamFunction.OnServerInvoke:Connect(function()
if finished == true then
return
else
game.ReplicatedStorage.RalseiCamFunction:InvokeClient()
end
end)
local player = game:GetService("Players").LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local camera = game.Workspace.CurrentCamera -- always use CurrentCamera to reference the camera
local tool = script.Parent
tool.MouseButton1Click:Connect(function()
game.ReplicatedStorage.RalseiCamFunction:InvokeServer()
if workspace.CurrentCamera and player.Character then
local humanoid = player.Character:FindFirstChildOfClass("Humanoid")
if humanoid then
workspace.CurrentCamera.CameraSubject = humanoid
end
end
end)
Scriptable is only for if you want to set the CFrame of the camera. What the OP is doing here is just setting the CameraSubject to the new character’s humanoid. Setting it to scriptable would not let the player rotate their camera.