So this is my GUI client for my door. I am wondering how I would edit it so that another condition is added that asks if the mouse is hovering over the door. Code:
local Player = game.Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local RunService = game:GetService("RunService")
local UserInputService = game:GetService("UserInputService")
local Door = game.Workspace.ButtonDoor.PrimeDoor
local DoorPart = Door.Door1
local DoorPrimaryPart = Door.PrimaryPart
local event = game.ReplicatedStorage.ToggleDoor
local NearDoor = false
RunService.RenderStepped:Connect(function()
if Player:DistanceFromCharacter(DoorPrimaryPart.Position) < 5 then
NearDoor = true
DoorPrimaryPart.EToOpen.Enabled = true
DoorPrimaryPart.EToOpen2.Enabled = true
else
NearDoor = false
DoorPrimaryPart.EToOpen.Enabled = false
DoorPrimaryPart.EToOpen2.Enabled = false
end
end)
UserInputService.InputBegan:Connect(function(Input)
if Input.UserInputType == Enum.UserInputType.Keyboard then
local Key = Input.KeyCode
if Key == Enum.KeyCode.E and NearDoor == true then
event:FireServer()
end
end
end)

1 comment
For the most part it works, I need to hover over the door to see the GUI, but when I then put the mouse off the door, it still shows the GUI.