I've managed to make a script that makes a text label visible when it hovers over a model. My question is, how do I; A) Make a table so it works on multiple models B) Make the gui be displayed only at a distance no larger than 16.
Thanks in advance.
Here's the code:
local RunService = game:GetService("RunService")
local Player = game:GetService("Players").LocalPlayer
local Mouse = Player:GetMouse()
local ActiveParts = workspace:WaitForChild("Door1")
local Tag = script.Parent
Tag.Text = "CLICK TO OPEN"
RunService.RenderStepped:connect(function()
local Target = Mouse.Target -- Get the object the mouse is hovering over
if Target and ActiveParts:IsAncestorOf(Target) then -- Check if the part is anywhere inside the model
Tag.Size = UDim2.new(0.1,Tag.TextBounds.X,0,25)
Tag.Visible = true
-- If no target exists, then...
else
-- Hide the tag
Tag.Visible = false
end
-- Update the tag's position with the mouse
Tag.Position = UDim2.new(0,Mouse.X-Tag.AbsoluteSize.X,0,Mouse.Y-Tag.AbsoluteSize.Y)
end)

3 comments
I guess i posted a bit late. Don't bother my answer under this one if this works
Players.Player1.PlayerGui.ScreenGui.Frame.TextLabel.re:8: attempt to index global 'plr' (a nil value)
Sorry I always use the variable 'plr' when defining the client :)