Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Mouse button up and down?

So I am trying to create a scope and I tested it using the Z key which's script I am pretty sure I long sense removed the scripting to. I want it to my tool activated the scope when mousebutton1 is down but deactivated the scope when mouse button1 is up but it won't work. It wants me to define "Mouse" and I am not sure what to make it.

Tool = script.Parent
Player = game.Players.LocalPlayer
Cam = game.Workspace.CurrentCamera

Tool.Unequipped:connect(function()
Cam.FieldOfView = 80
Player.CameraMode = "Classic"
if Player.PlayerGui:FindFirstChild("Scope") ~= nil then
Player.PlayerGui.Scope:Destroy()
end
end) 

Mouse.Button1Down: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)
Mouse.Button1Up:connect(function()
zoomed = false
Cam.FieldOfView = 80
Player.CameraMode = "Classic"
if Player.PlayerGui:FindFirstChild("Scope") ~= nil then
Player.PlayerGui.Scope:Destroy()
end
end)
Tool.Equipped:connect(function(Mouse)
end)

2 answers

✓ Accepted answer

So basically you script seems pretty stable, but you never defined mouse. In order to do this you have to us the :GetMouse() method. This can be dont by saying

Player:GetMouse()

Now you have the mouse, you have to define it as a variable, so it should turn out like this in the end

local mouse = Player:GetMouse()

~~Hope i helped

Well, you need to get your mouse

Player = game.LocalPlayer.Players
Mouse = Player:GetMouse() 

This discussion is preserved as it was. New answers, comments, and votes are closed.