Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Script runs when mouse button 1 or 2 is clicked?

Asked by
Ben_B 9
4 years ago

Id like to make it so it only works when left click (button 1) is clicked, thanks in advance!

01local enabled = true
02local ding = game.Workspace.Sounds.Ding             -- sound
03local part = game.Workspace.Configuration.DesertScout1  -- name
04local player = game.Players.LocalPlayer
05local mouse = player:GetMouse()
06local UserInputService = game:GetService("UserInputService")
07local PlayerGui = player:WaitForChild("PlayerGui")
08local toolup = PlayerGui:WaitForChild("clickE")
09local maxpickup = 20
10local gui = PlayerGui.HatUI.DesertScoutAdd
11 
12 
13 
14    UserInputService.InputBegan:Connect(function(input,gameProccesedEvent)
15 
View all 37 lines...

2 answers

Log in to vote
1
Answered by
OhManXDXD 445 Moderation Voter
4 years ago

Mouse.Button1Down isn't used here because of how UIS works. Instead, we look for the UserInputType MouseButton1

01local enabled = true
02local ding = game.Workspace.Sounds.Ding             -- sound
03local part = game.Workspace.Configuration.DesertScout1  -- name
04local player = game.Players.LocalPlayer
05local mouse = player:GetMouse()
06local UserInputService = game:GetService("UserInputService")
07local PlayerGui = player:WaitForChild("PlayerGui")
08local toolup = PlayerGui:WaitForChild("clickE")
09local maxpickup = 20
10local gui = PlayerGui.HatUI.DesertScoutAdd
11 
12 
13 
14    UserInputService.InputBegan:Connect(function(input,gameProccesedEvent)
15 
View all 37 lines...
Ad
Log in to vote
0
Answered by
Ben_B 9
4 years ago

It also runs when any button on the keyboard is presses.

Answer this question