|
| 17 Jun 2016 09:59 PM |
Alright, when a player joins I want there camera to be fixed in one spot, so I have this code in a script called CameraScript in StarterPlayerScripts:
local cam = workspace.CurrentCamera
cam.CoordinateFrame = CFrame.new(0, 0, 0) cam.Focus = CFrame.new(0, 0, 0) cam.CameraType = Enum.CameraType.Scriptable
Then once the player clicks a button I want the camera to return back to normal, so I have this code in the GUI button:
script.Parent.MouseButton1Down:connect(function() game.Workspace.CurrentCamera.CameraSubject = game.Players.LocalPlayer.Character.Humanoid game.Workspace.CurrentCamera.CameraType = "Custom" end)
The Problem is the camera isn't returning back to normal. It's staying in its scripted position. Can someone please explain what I'm doing wrong? Also if it matters these are local scripts so that it only effects the players camera. Thanks! |
|
|
| Report Abuse |
|
|
|
| 17 Jun 2016 10:23 PM |
Alright, so I added the script from the button into the CameraScript thinking that the CameraScript was overriding the script in the button. So, the script looks like this now:
cam = workspace.CurrentCamera local button = game.StarterGui.ScreenGui.MainMenu.Button player = game.Players.LocalPlayer
cam.CoordinateFrame = CFrame.new(0, 0, 0) cam.Focus = CFrame.new(0,0, 0) cam.CameraType = Enum.CameraType.Scriptable
Button.MouseButton1Down:connect(function() cam.CameraSubject = player.Character.Humanoid cam.CameraType = "Custom" end)
However, it still doesn't work. Can anyone help me with this? |
|
|
| Report Abuse |
|
|
| |
|
Mapyo
|
  |
| Joined: 04 Jun 2009 |
| Total Posts: 475 |
|
|
| 18 Jun 2016 12:09 AM |
I need something like this for my game, and I am kinda running into the same problem.
|
|
|
| Report Abuse |
|
|
|
| 18 Jun 2016 12:12 AM |
Well first of all I can tell you you're going to have even less success with the second script. Using the button inside of StarterGui guarantees that no player will ever press that. Use game.Players.LocalPlayer.PlayerGui... instead.
And secondly, the only suggestion I have is try to set the CameraType before the Subject. Not sure if that'll work.
|
|
|
| Report Abuse |
|
|
|
| 18 Jun 2016 12:21 AM |
Okay, I did as you said so the script looks like this now:
cam = workspace.CurrentCamera player = game.Players.LocalPlayer local button = player.PlayerGui.ScreenGui.MainMenu.Button
cam.CoordinateFrame = CFrame.new(0,0,0) cam.Focus = CFrame.new(0,0,0) cam.CameraType = Enum.CameraType.Scriptable
deploy.MouseButton1Down:connect(function() cam.CameraType = Enum.CameraType.Custom cam.CameraSubject = player.Character.Humanoid end)
It still doesn't work though. I even tried resetting the character. |
|
|
| Report Abuse |
|
|
| |
|
| |
|
Viikko
|
  |
| Joined: 23 Jan 2015 |
| Total Posts: 249 |
|
|
| 18 Jun 2016 12:51 PM |
| i actually made that into my old game let me check the scripts... |
|
|
| Report Abuse |
|
|
| |
|
Mapyo
|
  |
| Joined: 04 Jun 2009 |
| Total Posts: 475 |
|
| |
|
Raphael7
|
  |
| Joined: 03 Dec 2008 |
| Total Posts: 2479 |
|
|
| 18 Jun 2016 07:06 PM |
| Place the CameraType before you set focus and coordinateframe. |
|
|
| Report Abuse |
|
|
Mapyo
|
  |
| Joined: 04 Jun 2009 |
| Total Posts: 475 |
|
| |
|
|
| 18 Jun 2016 09:54 PM |
Alright did that and it still does not work heres the script:
cam = workspace.CurrentCamera player = game.Players.LocalPlayer local button = player.PlayerGui.ScreenGui.MainMenu.Button
cam.CameraType = Enum.CameraType.Scriptable cam.CoordinateFrame = CFrame.new(0,0,0) cam.Focus = CFrame.new(0,0,0)
button.MouseButton1Down:connect(function() cam.CameraType = Enum.CameraType.Custom cam.CameraSubject = player.Character.Humanoid end) |
|
|
| Report Abuse |
|
|
eRanged
|
  |
| Joined: 15 Jun 2013 |
| Total Posts: 9746 |
|
|
| 18 Jun 2016 10:56 PM |
It may be something wrong with the button instead of the Camera
Try adding print right after MouseButton1Click |
|
|
| Report Abuse |
|
|
|
| 18 Jun 2016 11:44 PM |
| Thats the only script there is now there isn't a script in the button. |
|
|
| Report Abuse |
|
|
eRanged
|
  |
| Joined: 15 Jun 2013 |
| Total Posts: 9746 |
|
|
| 19 Jun 2016 08:43 AM |
| I meant after the button1down function |
|
|
| Report Abuse |
|
|
|
| 19 Jun 2016 09:20 AM |
| I added in the print("Test") into the portion of the script that controls the button after the camera lines. It does print but camera still doesn't change. |
|
|
| Report Abuse |
|
|
eRanged
|
  |
| Joined: 15 Jun 2013 |
| Total Posts: 9746 |
|
|
| 19 Jun 2016 10:09 AM |
| hmm that's weird o_o idk man, but free bump! |
|
|
| Report Abuse |
|
|
eRanged
|
  |
| Joined: 15 Jun 2013 |
| Total Posts: 9746 |
|
| |
|
|
| 19 Jun 2016 11:15 AM |
| No there are no errors popping up in the output box. I even went and played the game and brought up the developer log and no errors in there either. |
|
|
| Report Abuse |
|
|