|
| 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 |
|
|
|
| 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 |
|
|
|
| 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 |
|
|
|
| 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 |
|
|
|
| 03 Nov 2014 06:04 PM |
| Okay. Thanks for the help. |
|
|
| Report Abuse |
|
|
|
| 03 Nov 2014 06:33 PM |
| The gui will still not be visible. How do I fix it? |
|
|
| Report Abuse |
|
|
| |
|
|
| 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 |
|
|
| |
|
Krosskode
|
  |
| Joined: 26 Aug 2010 |
| Total Posts: 11001 |
|
|
| 03 Nov 2014 08:19 PM |
| It's in a LocalScript, right? |
|
|
| Report Abuse |
|
|
|
| 03 Nov 2014 08:34 PM |
| Okay nevermind. I fixed it. |
|
|
| Report Abuse |
|
|