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.
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.