Answered by
7 years ago Edited 7 years ago
First off, the cameras position can not be changed when the player first joins, so we need to check for when the humanoid sits, and when it does, we need to change the camera type to scriptable, allowing us to change the camera's position. The way we would do this is by connecting the changed event to the humanoid and seeing if its sitting.
01 | game.Players.PlayerAdded:Connect( function (plr) |
02 | plr.CharacterAdded:Connect( function (char) |
03 | char.Humanoid.Changed:Connect( function () |
04 | if char.Humanoid.Sit = = true then |
06 | local CameraGui = game.ServerStorage.CameraGui:Clone() |
07 | CameraGui.Parent = plr.PlayerGui |
08 | CameraGui.Name = "CameraGui" |
09 | workspace.CurrentCamera.CameraType = Enum.CameraType.Scriptable |
11 | elseif char.Humanoid.Sit = = false then |
12 | if plr.PlayerGui:FindFirstChild( "CameraGui" ) then |
13 | plr.PlayerGui.CameraGui:Destroy() |
14 | workspace.CurrentCamera.CameraType = Enum.CameraType.Custom |
Ok, so now we have the GUI pop up when the player sits and dissapear when they stop sitting, but how do we actually change the camera's position, well first off, you will need a part somewhere in your plane called whatever you want, but in the next script, I will call it reference. Put a script in a text button inside the gui we cloned and put this in:
1 | script.Parent.MouseButton 1 Click:Connect( function () |
2 | workspace.CurrentCamera.CFrame = workspace.modelNameHere.Reference.CFrame |
Thats all there is to it. Hope I helped.
-Cmgtotalyawesome