Localscript within StarterPlayerScripts
-- Imagine you place a plate with 4 peices of 'food' on a table
game.Workspace.Interact.PlacedItems.ChildAdded:Connect(function(tool)
--Fires every time new plate added on table
if tool:IsA("Tool") then
if tool:FindFirstChild("Food") then
--Checks for Food folder
for _,v in pairs(tool.Food:GetChildren()) do
--Loops through the food(meshparts) in folder
local Click = v:WaitForChild("ClickDetector")
--Defines the ClickDetector inside the meshparts
Click.MouseHoverEnter:Connect(function()
--Fires when players mouse hovers over the 'food'.
print("test1") --print check
local highlight = Instance.new("Highlight")
highlight.FillTransparency = 1
highlight.Adornee = Click.Parent
highlight.Parent = Click.Parent
--Code to run a highlight effect around the food
print("test2") --print check 2
end)
Click.MouseHoverLeave:Connect(function()
--Fires when players mouse leaves the 'food'
print("test3") --print check 3
Click.Parent.Highlight:Destroy()
--Destroys the highlight effect
print("test4") --print check 4
end)
--More Code (unrelated)
end
end
end
end)
I made code as clearly labeled as possible
NONE of the print checks run
SOME of the food will highlight while others will not
as far as i'm concerned its completely random whether or not the food highlights or not
I have tested while looking inside the meshparts folders the highlight instance will appear ONLY on the food that highlights and will not appear at all on food that does not - this means its not a highlight issue - although highlights are buggy too but theres no highlight instances spawning at all within some foods.
If anyone knows whats going on please let me know