generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

Re: Camera

Previous Thread :: Next Thread 
austin10111213 is not online. austin10111213
Joined: 27 Nov 2008
Total Posts: 363
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
austin10111213 is not online. austin10111213
Joined: 27 Nov 2008
Total Posts: 363
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
austin10111213 is not online. austin10111213
Joined: 27 Nov 2008
Total Posts: 363
17 Jun 2016 11:39 PM
bump
Report Abuse
Mapyo is not online. 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
nicemike40 is not online. nicemike40
Joined: 19 Dec 2008
Total Posts: 1814
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
austin10111213 is not online. austin10111213
Joined: 27 Nov 2008
Total Posts: 363
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
austin10111213 is not online. austin10111213
Joined: 27 Nov 2008
Total Posts: 363
18 Jun 2016 10:57 AM
Anyone have any ideas?
Report Abuse
austin10111213 is not online. austin10111213
Joined: 27 Nov 2008
Total Posts: 363
18 Jun 2016 12:30 PM
bump2
Report Abuse
Viikko is not online. 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
austin10111213 is not online. austin10111213
Joined: 27 Nov 2008
Total Posts: 363
18 Jun 2016 12:58 PM
Alright Thanks
Report Abuse
Mapyo is not online. Mapyo
Joined: 04 Jun 2009
Total Posts: 475
18 Jun 2016 07:03 PM
bump


Report Abuse
Raphael7 is not online. 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 is not online. Mapyo
Joined: 04 Jun 2009
Total Posts: 475
18 Jun 2016 07:07 PM
Oh crud! Yeah!


Report Abuse
austin10111213 is not online. austin10111213
Joined: 27 Nov 2008
Total Posts: 363
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 is online. 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
austin10111213 is not online. austin10111213
Joined: 27 Nov 2008
Total Posts: 363
18 Jun 2016 11:44 PM
Thats the only script there is now there isn't a script in the button.
Report Abuse
eRanged is online. eRanged
Joined: 15 Jun 2013
Total Posts: 9746
19 Jun 2016 08:43 AM
I meant after the button1down function
Report Abuse
austin10111213 is not online. austin10111213
Joined: 27 Nov 2008
Total Posts: 363
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 is online. 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 is online. eRanged
Joined: 15 Jun 2013
Total Posts: 9746
19 Jun 2016 10:09 AM
No errors?
Report Abuse
austin10111213 is not online. austin10111213
Joined: 27 Nov 2008
Total Posts: 363
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
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image