I am currently trying to make a system that, when you hover over a drawer, a proximity prompt inside of that drawer becomes enabled.
The problem is, when you open the drawer, you have to unfocus your mouse on the drawer and then put it back on the drawer to be able to close it.
There are two proximity prompts in each of the drawers, and the names of the proximity prompts are: Open, and Close. They are both set to disabled.
There is also a bool value called ‘Show’ inside the drawer and it is default set to true
.
If the bool value is true and the mouse is hovered over the drawer, then the drawer will be opened, and the Close proximity prompt will be enabled. (meaning the player has the option to close the opened drawer)
The opposite goes for when the Show bool value is false.
Heres my code, it is a LocalScript
inside StarterGui
:
UIS.InputChanged:Connect(function(input)
if mouse.Target then
if mouse.Target.Name == "Drawer" then
if mouse.Target.Show.Value == true then
mouse.Target.Open.Enabled = true
end
if mouse.Target.Show.Value == false then
mouse.Target.Close.Enabled = true
end
else
for i, v in pairs(workspace:GetDescendants()) do
if v.Name == "Drawer" then
v.Open.Enabled = false
v.Close.Enabled = false
end
end
end
end
end)