How do I lock the camera in place and prevent the player from moving when they join the game?

I am trying to make a main menu where the background is is lush forest with a pond, and I need to know how to prevent the player from moving, and how to lock the camera in place.

I have tried using plugins, but they don’t work. Keep in mind that I mostly design guis, not program in lua.

I don’t know what category to put this in. If I am breaking a rule by putting this question here, please tell me. I will relocate it asap.

6 Likes

Ah yes, what you can do is pretty much just adjust the speed of the Character’s Humanoid on a Server Script, & lock the camera to a certain spot in a Local Script

I’ll give a brief code example:

--Server Script for preventing the player from moving
game.Players.PlayerAdded:Connect(function(Player)
    Player.CharacterAdded:Connect(function(Character)
        local Humanoid = Character:WaitForChild("Humanoid")
        Character.Humanoid.WalkSpeed = 0
    end)
end)

Basically what you’d wanna do is just create a PlayerAdded & CharacterAdded event for every Player that joins the game & every Character model that spawns in the workspace

API References:

1 Like

–Server Script for preventing the player from moving
game.Players.PlayerAdded:Connect(function(Player)
Player.CharacterAdded:Connect(function(Character)
local Humanoid = Character:WaitForChild(“Humanoid”)
Character.Humanoid.WalkSpeed = 0
local ccamera= game:GetService(" Workspace").CurrentCamera
ccamera.CameraType = Enum.CameraType.Scriptable
ccamera.CFrame = Position here
end)
end)
Sorry for my ugly code. Im om mobile

Question. Would that stop the player from falling?

I mean it depends on what way you really look on it, but if for some reason that did happen then you can fix it a couple of ways:

  • Add a box to prevent players from falling outta the game

  • Remove the Character upon spawning in

  • Disable collisions for each player

I should probably have created a new post for this but how do you do that?

You could literally just do

game.Players.PlayerAdded:Connect(function(Player)
    Player.CharacterAdded:Connect(function(Character)
        Character:Destroy()
    end)
end)

I believe, it’s nothing really complicated since the Character will be removed from the workspace upon first joining (Idk if you could make the Character equal to nil though), and then you can use LoadCharacter() if you want the Character to respawn back

1 Like

Thanks. I dont think i would need LoadCharacter() since the first part of my game is just GUI.

The moving code works perfect, thanks.

wait(0.5)
game.Workspace.Camera.CameraType="Scriptable" game.Workspace.Camera.CFrame = CFrame.new(game.Workspace.lol.Position, game.Workspace.fouspart.Position)

i tried this in a local script in workspace. When I start the game, the camera doesn’t move and there are no errors. why is this happening? (ignore the names i was in a rush)

1 Like

Try this:

--Put this in StarterPlayerScripts in a LocalScript, not a SERVER SCRIPT
local Camera = workspace.CurrentCamera
Camera.CameraType = Enum.CameraType.Scriptable
Camera.CFrame = CFrame.new(game.Workspace.lol.Position, game.Workspace.fouspart.Position)

Yeah side note, but LocalScripts only work client-sided

workspace is server-sided, so you can’t do that

6 Likes

so that in the menu the player cannot change the camera type in the settings, try this:

1. 
2. if Camera.CameraType ~= Enum.CameraType.Scriptable then
3. 	Camera.CameraType = Enum.CameraType.Scriptable;
4. end
5.