I have a system of text button teleporters, but you can click them from miles away, any way to set a range on them?
There is a property for BillboardGuis called MaxDistance (found here → BillboardGui | Documentation - Roblox Creator Hub). With this you can set the max distance away in studs that the player can see and click the text button.
If you calculate the magnitude of a player’s position and the part that the text button is parented to, you can create a max distance like activation similar to click detectors.
Example:
local Character = Player.Character
local HumanoidRootPart = Character:FindFirstChild("HumanoidRootPart")
local Part = workspace.Part
local TextButton = Part.SurfaceGui.Button
local MaxDistance = 5
--put the code below in a loop
if (HumanoidRootPart.Position - Part.Position).Magnitude > MaxDistance then
TextButton.Visible = false
else
TextButton.Visible = true
end
Note:
This is specific for surface guis only.
Im confused? Do you have a place that I could reference.
But I use surfacegui, any help with soemthing like that, because surfacegui does not have a maxdistance
I used the wrong operation in my example, I corrected it
Here’s a place file with that I was talking about:
Max Distance Button.rbxl (17.5 KB)
Thank you, ill test this out
Ah my bad, you did not class if it was either a billboardgui or surfacegui so I guessed you used a billboardgui.