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 » Scripting Helpers
Home Search
 

Re: Telescope Script Help

Previous Thread :: Next Thread 
ToastedGarlic is not online. ToastedGarlic
Joined: 10 Mar 2012
Total Posts: 3325
03 Nov 2014 05:12 PM
I'm trying to make a telescope tool that lets you see far away things, but the GUI and the CameraMode won't change when I unequip the tool. The script:

local cam = workspace.CurrentCamera
local tool = script.Parent
local player = game.Players.LocalPlayer
local gui = nil
gui = tool.Scope:clone()
gui.Parent = player.PlayerGui

tool.Equipped:connect(function()
gui.ImageLabel.Size = UDim2.new(0, 1000, 0, 1000)
game.Players.LocalPlayer.CameraMode = Enum.CameraMode.LockFirstPerson
cam.FieldOfView = 30
end)

game.StarterPack.Telescope.Unequipped:connect(function()
gui.ImageLabel.Size = UDim2.new(0, 0, 0, 0)
game.Players.LocalPlayer.CameraMode = Enum.CameraMode.Classic
cam.FieldOfView = 70
end)

How do I fix this?
Report Abuse
AdorableFerretsRus is not online. AdorableFerretsRus
Joined: 27 May 2012
Total Posts: 3903
03 Nov 2014 05:14 PM
Try copying the script, adding comments, then pasting it back in so we understand a little better
Report Abuse
ToastedGarlic is not online. ToastedGarlic
Joined: 10 Mar 2012
Total Posts: 3325
03 Nov 2014 05:31 PM
local cam = workspace.CurrentCamera
local tool = script.Parent
local player = game.Players.LocalPlayer
local gui = nil --The gui
gui = tool.Scope:clone()
gui.Parent = player.PlayerGui

tool.Equipped:connect(function() --When equipped
gui.ImageLabel.Size = UDim2.new(0, 1000, 0, 1000) --The size the GUI is going to be when equipped
game.Players.LocalPlayer.CameraMode = Enum.CameraMode.LockFirstPerson --The Cameramode
cam.FieldOfView = 30 --How much the the zoom in of the camera will be
end)

game.StarterPack.Telescope.Unequipped:connect(function()
gui.ImageLabel.Size = UDim2.new(0, 0, 0, 0) --The size the GUI is going to be when unequipped
game.Players.LocalPlayer.CameraMode = Enum.CameraMode.Classic --The Cameramode
cam.FieldOfView = 70
end)
Report Abuse
SuperAlpacaMan is not online. SuperAlpacaMan
Joined: 18 Nov 2008
Total Posts: 774
03 Nov 2014 05:40 PM
It looks like you're changing the visibility of the gui by setting the size to 0-- just use the .Visible property instead.

Your problem is probably a typo though--you're listening for the starterpack's tool to unequip (event never fires) instead of the player's.

game.StarterPack.Telescope.Unequipped:connect(function() --> tool.Unequipped:connect(function()
Report Abuse
ToastedGarlic is not online. ToastedGarlic
Joined: 10 Mar 2012
Total Posts: 3325
03 Nov 2014 06:04 PM
Okay. Thanks for the help.
Report Abuse
ToastedGarlic is not online. ToastedGarlic
Joined: 10 Mar 2012
Total Posts: 3325
03 Nov 2014 06:33 PM
The gui will still not be visible. How do I fix it?
Report Abuse
ToastedGarlic is not online. ToastedGarlic
Joined: 10 Mar 2012
Total Posts: 3325
03 Nov 2014 06:34 PM
Nevermind. I fixed it.
Report Abuse
ToastedGarlic is not online. ToastedGarlic
Joined: 10 Mar 2012
Total Posts: 3325
03 Nov 2014 07:46 PM
Now I got another problem. The error says this:
Players.Player1.Backpack.Telescope.Script:5: attempt to index local 'player' (a nil value)

The script:
local cam = workspace.CurrentCamera
tool = script.Parent
local player = game.Players.LocalPlayer
gui = tool.Scope:clone()
gui.Parent = player.PlayerGui

tool.Equipped:connect(function()
gui.ImageLabel.Visible = true
game.Players.LocalPlayer.CameraMode = Enum.CameraMode.LockFirstPerson
cam.FieldOfView = 10
end)

tool.Unequipped:connect(function()
gui.ImageLabel.Visible = false
game.Players.LocalPlayer.CameraMode = Enum.CameraMode.Classic
cam.FieldOfView = 70
end)

Report Abuse
ToastedGarlic is not online. ToastedGarlic
Joined: 10 Mar 2012
Total Posts: 3325
03 Nov 2014 08:05 PM
Please I need help
Report Abuse
Krosskode is not online. Krosskode
Joined: 26 Aug 2010
Total Posts: 11001
03 Nov 2014 08:19 PM
It's in a LocalScript, right?
Report Abuse
ToastedGarlic is not online. ToastedGarlic
Joined: 10 Mar 2012
Total Posts: 3325
03 Nov 2014 08:34 PM
Okay nevermind. I fixed it.
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • 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