Hello! I’m trying to make it so that whenever the player hovers their mouse (and is in range) over the doors of a drawer, a billboardgui inside the drawer becomes visible and when the player stops hovering or gets out of range it cant be seen anymore.
For some reason getting out of range works, but even after the player’s mouse stops hovering the billboardgui is still visible. Can anybody help me?
local Player = game.Players.LocalPlayer
local Mouse = Player:GetMouse()
local RunService = game:GetService("RunService")
local caninteract
RunService.RenderStepped:Connect (function()
if Mouse.Target.Name == 'Door1' or Mouse.Target.Name == 'Door2' then
if Mouse.Target.Parent.Name == "Drawer" then
local pos1 = Mouse.Target.Position
local pos2 = Player.Character.Torso.Position
local magnitude = (pos1 - pos2).magnitude
if magnitude <=5 and Mouse.Target then
caninteract = true
local interactpart = Mouse.Target.Parent:FindFirstChild("InteractPart")
local bil = interactpart:FindFirstChild("BillboardGui")
bil.Enabled = true
elseif magnitude >5 then
caninteract = false
local interactpart = Mouse.Target.Parent:FindFirstChild("InteractPart")
local bil = interactpart:FindFirstChild("BillboardGui")
bil.Enabled = false
end
end
end
end)