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

the function should only runs if user has right mouse button held down on a button.How do i do it?

Asked by 4 years ago
Edited 4 years ago
01local UIS = game:GetService("UserInputService")
02local runService = game:GetService("RunService")
03--local
04local player = game.Players.LocalPlayer
05local slider = script.Parent
06local sliderbar = script.Parent.Parent
07local Bckcolor = script.Parent.Parent.Color
08local held = false
09UIS.InputBegan:Connect(function(Input, Processed)
10    if Input.UserInputType == Enum.UserInputType.MouseButton1 then
11        held = true
12    end
13end)
14UIS.InputEnded:Connect(function(Input, Processed)
15    held = false
View all 27 lines...
0
did you get this off a video? iiDevPanda 43 — 4y
0
nope mikey2019d 43 — 4y
0
THIS QUESTION HAS BEEN ANSWERED BY ME mikey2019d 43 — 4y

3 answers

Log in to vote
0
Answered by 4 years ago
Edited 4 years ago

Do a while true do when the held is true

For example

1while held = true do
2    --function here
3end
0
Might need wait cause it could break from how fast this is running PixelRankYT 20 — 4y
0
Oh ok thank you, will try mikey2019d 43 — 4y
Ad
Log in to vote
0
Answered by
uhi_o 417 Moderation Voter
4 years ago

There is a RBXScriptSignal called Button2Down that comes with the mouse

1game.Players.LocalPlayer:GetMouse().Button2Down:Connect(function()
2    print("Player is holding down right click")
3end)

https://developer.roblox.com/en-us/api-reference/event/Mouse/Button2Down

Log in to vote
0
Answered by 4 years ago
01local UIS = game:GetService("UserInputService")
02local runService = game:GetService("RunService")
03local SN = script.Parent.Parent.Parent.Parent.SoundNumber.Number
04local player = game.Players.LocalPlayer
05local slider = script.Parent
06local sliderbar = script.Parent.Parent
07local Bckcolor = script.Parent.Parent.Color
08local part = script.Parent.Parent.Parent.range
09local held = false
10UIS.InputBegan:Connect(function(Input, Processed)
11    if Input.UserInputType == Enum.UserInputType.MouseButton1 then
12        part.MouseEnter:Connect(function()
13            slider.MouseButton1Down:Connect(function()
14                held = true
15            end)
View all 42 lines...

Answer this question