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.
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
–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
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
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)
--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