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

How would I track these both in one script?

Asked by 7 years ago
Edited 7 years ago

So what I'm trying to make is make a script track 1) If the player is hovering over the brick and 2) If they pressed a key while hovering over that brick. Much appreciated.

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

Mouse.Move:connect(function()
    if Mouse.Target and Mouse.Target == workspace.Door1 then
       workspace.Door1.ekey.Enabled = true
        print("Im on it")
    elseif Mouse.Target and Mouse.Target ~= workspace.Door1 then
        workspace.Door1.ekey.Enabled = false
    end
end)

function onKeyDown(key)
            key = key:lower()
            if key == "e" and Mouse.Target == workspace.Door1 then
            print("E pressed over the brick")
        end 
    end

Answer this question