So I basically was trying to make a sniper gui when you zoom in but I've been having problems when I finished the code. The sniper scope and gui worked fine but once I've done it once on the sniper it works on the other tools like ak and pistol ect. Here is some of my code Main code
local UIS = game:GetService("UserInputService") local Player = game.Players.LocalPlayer local Camera = workspace.CurrentCamera local mouse = game.Players.LocalPlayer:GetMouse() local tool = script.Parent local transparent = game.StarterGui.Scope.Frame.ImageLabel local rep = game.ReplicatedStorage mouse.Button2Down:Connect(function() Camera.FieldOfView = 30 rep.Gui:FireServer() script.Parent.Handle.Transparency = 1 end) mouse.Button2Up:Connect(function() Camera.FieldOfView = 70 rep.GuiOff:FireServer() script.Parent.Handle.Transparency = 0 end)
Trigger gui code
local rep = game.ReplicatedStorage game.Workspace.Snipa.Equipped:Connect(function() rep.Gui.OnServerEvent:Connect(function(player) script.Parent.ImageLabel.ImageTransparency = 0 end) rep.GuiOff.OnServerEvent:Connect(function(player) script.Parent.ImageLabel.ImageTransparency = 1 end) end)``
Thanks to any help.
local UIS = game:GetService("UserInputService") local Player = game.Players.LocalPlayer local Camera = workspace.CurrentCamera local mouse = game.Players.LocalPlayer:GetMouse() local tool = script.Parent local transparent = game.StarterGui.Scope.Frame.ImageLabel local rep = game.ReplicatedStorage tool.Activated:Connect(function() Camera.FieldOfView = 30 rep.Gui:FireServer() script.Parent.Handle.Transparency = 1 end) tool.Deactivated:Connect(function() Camera.FieldOfView = 70 rep.GuiOff:FireServer() script.Parent.Handle.Transparency = 0 end)
Probably this will work