I am currently trying to make an alternative method for a clickable custom proximity prompt using ImageButtons. A BillboardGui shows up whenever the player’s mouse hovers over an object that has the name: “Drawer”. The BillboardGui includes an ImageButton which, once is clicked, is supposed to do the same function that the regular proximityprompt does when you press ‘E’ on the keyboard.
Here is the mouse local script:
local UIS = game:GetService("UserInputService")
local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
game:GetService("RunService").Stepped: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
if game.ReplicatedStorage:FindFirstChild("Highlight") then
game.ReplicatedStorage.Highlight.Parent = mouse.Target
player.PlayerGui.BillboardGui.Enabled = true
player.PlayerGui.BillboardGui.Adornee = mouse.Target
local drawereference = game.ReplicatedStorage.DrawerReference
drawereference:FireServer(mouse.Target, mouse.Target.Show.Value) -- The 'Show' value is basically telling if the proximity prompt is the 'Close' proximity prompt, or the 'Open' proximity prompt.
end
else
for i, v in pairs(workspace:GetDescendants()) do -- This just disables all the proximity prompts inside of the drawer.
if v.Name == "Drawer" then
v.Open.Enabled = false
v.Close.Enabled = false
player.PlayerGui.BillboardGui.Enabled = false
player.PlayerGui.BillboardGui.Adornee = nil
if v:FindFirstChild("Highlight") then
v.Highlight.Parent = game.ReplicatedStorage
end
end
end
end
end
end)
Here is the ImageButton script (btw the ImageButton is located inside a BillboardGui inside of the PlayerGui):
game.ReplicatedStorage.DrawerReference.OnServerEvent:Connect(function(p, drawer, val)
script.Parent.MouseButton1Click:Connect(function()
local tweenservice = game:GetService("TweenService")
local draweropen = tweenservice:Create(drawer, TweenInfo.new(1, Enum.EasingStyle.Linear, Enum.EasingDirection.In, 0, false, 0), {Position = drawer.OpenDrawer.Position})
local drawerclose = tweenservice:Create(drawer, TweenInfo.new(1, Enum.EasingStyle.Linear, Enum.EasingDirection.In, 0, false, 0), {Position = drawer.ClosedDrawer.Position})
if drawer:FindFirstChild("Show") then
if val == true then
print("true")
drawer.Open.Enabled = false
drawer.Show.Value = false
drawer.Close.Enabled = true
draweropen:Play()
game.ReplicatedStorage.PlaySound:FireAllClients(game.ReplicatedStorage.Audios.Drawer)
end
if val == false then
print("false")
drawer.Open.Enabled = true
drawer.Show.Value = true
drawer.Close.Enabled = false
drawerclose:Play()
game.ReplicatedStorage.PlaySound:FireAllClients(game.ReplicatedStorage.Audios.Drawer)
end
end
end)
end)