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?
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.
01 | local player = game:GetService( "Players" ).LocalPlayer |
02 |
03 | local mouse = player:GetMouse() |
04 |
05 |
06 | --main script |
07 | mouse.Move:Connect( function () |
08 | script.Parent.Position = UDim 2. new( 0 , mouse.X + 5 , 0 , mouse.Y + 10 ) -- location of the Gui |
09 | script.Parent.Visible = false |
10 | local target = mouse.Target |
11 | if target and target.Parent then |
12 | 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 |
13 | script.Parent.Text = target.Parent.Name |
14 | script.Parent.Visible = true |
15 | end |
Please do comment this if you want a other version.