When a new player joins my game, I want to control their camera and point it somewhere specific until they push the “play button” to join the players in the server in the lobby. I use a playeradded even on the server to detect a player joining and then use a remote event to signal over to the client to grab the camera and point it where i want it. The code works as intended but their is sometimes a momentary glitch as if the camera is loaded and fixed for a split second before my code can grab it. This makes the intro camera appear in one place and then suddenly appear where i want it. Below is a video of the camera working properly…
now here is a video of the momentary glitch…
Both results are from the same code. below here is the sever side detecting the player added event…
game:GetService("Players").PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(char)
end)
local userId = player.UserId
print(userId)
local clonedDescription = game.Players:GetHumanoidDescriptionFromUserId(userId)
--accessories
clonedDescription.BackAccessory = ""
clonedDescription.FaceAccessory = ""
clonedDescription.FrontAccessory = ""
clonedDescription.HatAccessory = ""
clonedDescription.NeckAccessory = ""
clonedDescription.ShouldersAccessory = ""
clonedDescription.WaistAccessory = ""
-- clothes
clonedDescription.GraphicTShirt = 0
--body parts
clonedDescription.Head = 0
clonedDescription.LeftArm = 0
clonedDescription.LeftLeg = 0
clonedDescription.RightArm = 0
clonedDescription.RightLeg = 0
clonedDescription.Torso = 0
--scale
clonedDescription.BodyTypeScale = 0.64
clonedDescription.DepthScale = 1
clonedDescription.HeightScale = 1
clonedDescription.HeightScale = .9
clonedDescription.ProportionScale = .86
clonedDescription.WidthScale = 1
-- Spawn character with the HumanoidDescription
player:LoadCharacterWithHumanoidDescription(clonedDescription)
game:GetService("ReplicatedStorage").RemoteEvents:WaitForChild("MenuRoom"):FireClient(player)
end)
Now here is the local script to listen for the event and take control of the camera…
Now here is the code for the local script detecting the player added to control the camera...
```replicatedStorage.RemoteEvents:WaitForChild("MenuRoom").OnClientEvent:Connect(function()
local menuRoom = replicatedStorage:WaitForChild("MenuRoom"):Clone()
local camera = game.Workspace.Camera
camera.CameraType = Enum.CameraType.Scriptable
camera.CFrame = CFrame.new(menuRoom.CameraPart.Position,menuRoom.CameraPart2.Position)
introMenu.Visible = true
menuRoom.Parent = game.Workspace
end)
A Few things i have tried…
- moving the remote event signal into the character added event and at the top of the player added event.
- directly controlling the camera on the local script “at line # 1” without waiting for a remote event.
- setting game.Players.CharacterAutoLoads = false at line 1 of the server script. This way no Character Avatar loads into the world at all. But it seems I can not control a Camera without an avatar.
- removed the custom loaded character in the server side script seen as humanoid description and instead allowing the roblox natural character to load.
No matter, the results are always as seen in the video. It’s as if roblox grabs the camera before any character avatar has loaded into the world and fixes it in a location. If a character loads then the cameratype changes from fixed to custom. but it also seems that I can’t get ahead of that. Any ideas? I just feel the glitchy issue is not smooth and makes my code look gimpy.