Hello. I am trying to have a custom camera that will be set during an intermission.
As for now, the logic of my code goes as follows.
I have a remote event triggered whenever a character is loaded, a local script in starter player scripts will then change the camera CFrame when this remote event is activated.
I can confirm the code below (local script) runs because I placed a few debugging prints.
game.ReplicatedStorage.Camera.OnClientEvent:Connect(function(plr)
print("okay it started")
local newcam = workspace.CameraBlock
local camera = workspace.CurrentCamera
camera.CameraType = Enum.CameraType.Scriptable
camera.CFrame = newcam.CFrame
print("Okay its done")
end)
Nothing happens to the camera and it is not changed.
On the surface, is there anything wrong with my code?
I tested this same thing, and it worked just fine for me. Also, I should let you know that you do not need “plr” after the :Connect (OnClientEvent only happens in local scripts, and the player is implied)
game.ReplicatedStorage.Camera.OnClientEvent:Connect(function()
print("okay it started")
local newcam = workspace.CameraBlock
local camera = workspace.CurrentCamera
camera.CameraType = Enum.CameraType.Scriptable
camera.CFrame = newcam.CFrame
print("Okay its done")
end)
Could you show me how you fired your remote event?
I have a script that is in charge of re spawning the player on game command. The full script is below.
game.Players.CharacterAutoLoads = false
game.Players.PlayerAdded:Connect(function(player)
local inter = player:WaitForChild("secondaryStats").InterVal
player.CharacterAdded:Connect(function(character)
local Cam = game.ReplicatedStorage.Camera
Cam:FireClient(player)
local humanoid = character:FindFirstChild("Humanoid")
if humanoid then
humanoid.Died:Connect(function()
inter.Value = true
print('inter value was set to true')
player:LoadCharacter()
end)
end
end)
player:LoadCharacter()
end)
game.ReplicatedStorage.Reload.OnServerEvent:connect(function(player)
player.secondaryStats.InterVal.Value = false
player:LoadCharacter()
end)
you can find the code for the Remote Event in lines 8-9
I have it set like this because in short, this is what I am trying to achieve.
When a player is loaded or died, they are brought out of the playing field so they won’t die and their GUI’s become a cinematic thing with a custom camera + GUI. Once they select play, their player is reloaded into the main world. If they die and their intermission value is set to true, they are teleported to the intermission box and their cameras are set to the special camera if in said screen.
Thanks both of you for the help. I actually solved the problem by adding a quick wait statement to the local script. It seems that my camera was being set to the new location prior to the player being loaded into the testing room.