In my game, I want there to be objects where if you hover over them, a certain gui appears. I can't just reference it, because the item could be destroyed or cloned in a certain part of the game. I can't think of any way to do this. What can I do for this?
COMMUNITY QUESTION
How to make a gui appear once it hovers over a part?
1 answer
If you want to make a gui apper when the mouse is hovering a part and name it whatever then it you would want to make a screengui and add a TextLabel in the screengui. Insert a local script in the **TextLabel **and type this.
local player = game:GetService("Players").LocalPlayer
local mouse = player:GetMouse()
--main script
mouse.Move:Connect(function()
script.Parent.Position = UDim2.new(0, mouse.X + 5, 0, mouse.Y + 10) -- location of the Gui
script.Parent.Visible = false
local target = mouse.Target
if target and target.Parent then
if target.Parent.ClassName == "Model" then -- if the object that you're mouse is hovering is a model then the name of the object will show
script.Parent.Text = target.Parent.Name
script.Parent.Visible = true
end
if target.Parent:FindFirstChild("HumanoidRootPart") then
script.Parent.Text = target.Parent.Name
script.Parent.Visible = true
end
if target:FindFirstChild("Mouseover") then
script.Parent.Text = target.Mouseover.Value
script.Parent.Visible = true
end
end
end)
Please do comment this if you want a other version.
This discussion is preserved as it was. New answers, comments, and votes are closed.

4 comments
How can I make it so that it can only be activated if a player is withing a stud distance, and if they leave it, the gui will tween out aswell?
Ok i will edit this
Ok i will edit this
If you want to make a distance then you can use magnitude or learn it