Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

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

Asked by 4 years ago

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

Log in to vote
0
Answered by 4 years ago
Edited 4 years ago

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.

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? DejaSketch 84 — 4y
0
Ok i will edit this Eric_pokemon 133 — 4y
0
Ok i will edit this Eric_pokemon 133 — 4y
0
If you want to make a distance then you can use magnitude or learn it Eric_pokemon 133 — 4y
Ad

Answer this question