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

How can i make it so that once a button is being held. Other UIS won't work?

Asked by 5 years ago

I really don't under stand how i can stop one a UIS from working once another button is being held. I've gotten idea's that you have to use the statement elseif. But no clues to do with to do with thatelseifI've also tried telling the script that once a button is pressed all other UIS debounes will be set to false. And once they let go it will be set to true. But that did not work. This was my script.

local Player = game.Players.LocalPlayer
local char = Player.Character
local en = true
local den = true
local UIS = game:GetService("UserInputService")

UIS.InputBegan:Connect(function(Input)
    if Input.KeyCode == Enum.KeyCode.Q then
if not en then return end
if den == false then
    deb = false
en = false
Part = Instance.new("Part")
Part.Parent = workspace
Part.CFrame = char.Head.CFrame * CFrame.new(0,0,-5)
    end
end
end)

UIS.InputEnded:Connect(function(Input)
    if Input.KeyCode == Enum.KeyCode.Q then
        Part:Destroy()
den = true
    end
end)

UIS.InputBegan:Connect(function(Input)
    if Input.KeyCode == Enum.KeyCode.E then
    if not den then return end
    if en == false then 
        en = false
 Part2 = Instance.new("Part")
Part2.Parent = workspace
Part2.CFrame = char.Head.CFrame * CFrame.new(0,0,-5)
wait(3)
den = false
    end
end
end)

UIS.InputEnded:Connect(function(Input)
    if Input.KeyCode == Enum.KeyCode.E then
        Part2:Destroy()
en = true
    end
end)

Any help with be apreciated!

0
Why do you have separate events? You only need one of each. User#19524 175 — 5y

Answer this question