-
When a player hovers over a specific Part a GUI with the parts Name, and Health popup along with the Highlight
-
It works fine but the only Issue is that when I load into the game it works or it doesn’t I dont understand why it will only work half the time
-
I have tried looking for similar issues on the forum with nothing that similar that I could implement I have also tried adding loading times to it thinking that my code hasn’t loaded yet but I’m not sure thats the case
This is my code:
local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
local StarterGUI = game:GetService("StarterGui")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Collection = game:GetService("CollectionService")
local ToolEquiped = ReplicatedStorage.Values.Equipped.Value
mouse.Move:Connect(function()
if not mouse.Target then script.Highlight.Adornee = nil return end --Highlights
if Collection:HasTag(mouse.Target, "Highlitable") then
script.Highlight.Adornee = mouse.Target
return
elseif Collection:HasTag(mouse.Target.Parent, "Highlitable") then
script.Highlight.Adornee = mouse.Target.Parent
return
end
script.Highlight.Adornee = nil -- Unhighlights
end)
--Health Popup
wait(3)
local parts = game.Workspace.Rocks.Rock2
local ClickDetector = parts.ClickDetector
ClickDetector.MouseHoverEnter:Connect(function()
player.PlayerGui.MineGUI.RockHealth.Visible = true
print("entered")
end)
ClickDetector.MouseHoverLeave:Connect(function()
player.PlayerGui.MineGUI.RockHealth.Visible = false
print("Left")
end)