I made a script (if your from another question your probably a bit familiar with it) and its suppose to display a scope when the right button is clicked and retract it when its up. Of course I want it so that the scope only works when the tool its in is enabled (Being used) For some odd reason it is able to open the scope even when the tool is disabled(Not in use) Please help!!
Tool = script.Parent
Player = game.Players.LocalPlayer
Cam = game.Workspace.CurrentCamera
local Mouse = Player:GetMouse()
Tool.Unequipped:connect(function()
Cam.FieldOfView = 80
Player.CameraMode = "Classic"
if Player.PlayerGui:FindFirstChild("Scope") == nil then
Player.PlayerGui.Scope:Destroy()
end
end)
Tool.Equipped:connect(function()
Mouse.Button2Down:connect(function()
zoomed = true
Cam.FieldOfView = 20
Player.CameraMode = "LockFirstPerson"
if Player.PlayerGui:FindFirstChild("Scope") == nil then
script.Parent.Scope:Clone().Parent = Player.PlayerGui
end
end)
end)
Tool.Unequipped:connect(function()
if Player.PlayerGui:FindFirstChild("Scope") == true then
Player.CameraMode = "Classic"
zoomed = false
Cam.FieldOfView = 80
Player.PlayerGui.Scope:Destroy()
end
end)
Mouse.Button2Up:connect(function()
Player.CameraMode = "Classic"
zoomed = false
Cam.FieldOfView = 80
Player.PlayerGui.Scope:Destroy()
end)
Mouse.Button2Up:connect(function()
if Player.PlayerGui:FindFirstChild("Scope") == true then
Player.CameraMode = "Classic"
zoomed = false
Cam.FieldOfView = 80
Player.PlayerGui.Scope:Destroy()
end
end)
I get 0 errors

2 comments
but I don't want to use values. Those can be slow and not always instant. Just doing it straight from a script is easier.
You don't need values, you need variables.