Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How to make a gui appear once it hovers over a part?

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?

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.

4 comments

0

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?

0

Ok i will edit this

0

Ok i will edit this

0

If you want to make a distance then you can use magnitude or learn it

This discussion is preserved as it was. New answers, comments, and votes are closed.