-
I want to make it so any part in a specific folder in the workspace will allow certain functions to happen for example hovering over a part to display its health
-
I keep getting this error
Players.DAPANDA_KinG.PlayerScripts.LocalHighlighter:38: attempt to index nil with ‘MouseHoverEnter’
Im assuming its not calling any clickdetector -
Before it was working when I had just one part but I want to incorperate many parts for one function is it possible?
This is the code im using to highlight any parts with Tag highlitable and display the Health of any parts in the game.workspace.Rocks folder
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 MinableBlocks = game.Workspace.Rocks:GetChildren()
local ClickDetector = MinableBlocks.ClickDetector
if MinableBlocks then
ClickDetector.MouseHoverEnter:Connect(function()
player.PlayerGui.MineGUI.RockHealth.Visible = true
end)
ClickDetector.MouseHoverLeave:Connect(function()
player.PlayerGui.MineGUI.RockHealth.Visible = false
end)
end
Feel free to ask for more details and anything helps thank you!