The game I’m working on this cannot use proximityprompts due to the way the camera works, but is there a way to do this? Like if the player touches an invisible part the GUI opens and then closes when the player leaves that invisible part?
You can open/close the GUI on touched events if that is what you’re asking. You can learn about it here.
For example:
local OpenBrick = workspace.OpenBrick
local CloseBrick = workspace.CloseBrick
local function OpenUI(hit)
if hit.Parent:FindFirstChildWhichIsA("Humanoid") then
-- make ui visible
end
end
local function CloseUI(hit)
if hit.Parent:FindFirstChildWhichIsA("Humanoid") then
-- make ui invisible
end
end
OpenBrick.Touched:Connect(OpenUI)
CloseBrick.Touched:Connect(CloseUI)
sorry for the late response, but i’m trying to use a singular part to trigger and un-trigger the GUI. Like it starts when touched and ends when untouched
How about Magnitude?
You can use Magnitude to measure the distance between two different objects, let that be the player and a part or two different parts.
I say, run a while true loop and check whether the Player HumanoidRootPart is near the part and make the GUI visible if the HumanoidRootPart is within a certain range.
Example:
local Range = 10 -- Range
while true do
Frame["Visible"] = false -- Frame
for Int, Item in pairs(workspace:GetChildren()) do -- Assuming the part is in the Workspace
if Item:IsA("BasePart") and Item["Name"] == "Part" then -- Checking if its a part and has the name "Part"
local Magnitude = (Item["Position"] - HumanoidRootPart["Position"])["magnitude"]
if Magnitude <= Range then -- Checking whether the HumanoidRootPart is less than the given Range
local Position = CurrentCamera:WorldToScreenPoint(Item["Position"])
Frame["Visible"] = true -- Making the GUI visible
Frame["Position"] = UDim2.new(0, Position["X"], 0, Position["Y"], 0)
end
end
end
wait()
end
I ended up using Touched and TouchEnded
Update again: i’m not using Touched and TouchEnded anymore, because they’re completely unreliable and I’m Switching to ZonePlus instead