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

How can i check if a player is in a specific area and holds a button?

Asked by 5 years ago

So basically i want to check if a player is in a specific place (i used onTouch) , and i want to see if the player holds a button in that area, but nothing happens with my code:

local sensor = script.Parent
local function onTouch(sensor)
    KeyHeld = false
function onKeyPress(inputObject,gameProcessed)
    if inputObject.KeyCode == Enum.KeyCode.V then
        KeyHeld = true
        while KeyHeld do
        -- code
        wait()
        end
    end
end

function onKeyRelease(inputObject,game.Processed)
    if inputObject.KeyCode == Enum.KeyCode.V then
        KeyHeld = false
    end
game:GetService("UserInputService").InputBegan:connect(onKeyPress)
game:GetService("UserInputService").InputEnded:connect(onKeyRelease)
end
0
Use region3, then check the inventory for that button. Thesquid13 301 — 5y
0
^ starmaq 1290 — 5y

Answer this question