The problem with this is that after duplicating a pumpkin it seems as if the script of the first pumpkin applies onto the duplicated one ( aka if the first one is hovered over BOTH pumpkins are highlighted ). I have absolutely no idea how this could be since scripts don’t communicate with each other unless you make them.
Here’s the script (this is the same for all pumpkins):
--Variables
local Pumpkin = script.Parent
local ClickDetector = Pumpkin.ClickDetector
local Highlight = Pumpkin.Highlight
function HighlightOn()
Highlight.Enabled = true
end
function HighlightOff()
Highlight.Enabled = false
end
ClickDetector.MouseHoverEnter:Connect(HighlightOn)
ClickDetector.MouseHoverLeave:Connect(HighlightOff)
The thing about this is, in other games they use the exact same system as I do however their highlights don’t glitch as mine do and I think I know as to why this is.
EDIT:
I found the problem. So for some reason while running in studio this glitches, but when you actually play the place in Roblox this glitch is fixed.
Should Work on the items separately, Put In ServerScriptService:
function HighlightOn(Object)
Object.Enabled = true
end
function HighlightOff(Object)
Object.Enabled = false
end
for _,HL in pairs(workspace.HL:GetChildren()) do -- Random Name of my Folder
if HL:IsA("Part") then
HL.ClickDetector.MouseHoverEnter:Connect(function()
HighlightOn(HL:FindFirstChildOfClass("Highlight"))
end)
HL.ClickDetector.MouseHoverLeave:Connect(function()
HighlightOff(HL:FindFirstChildOfClass("Highlight"))
end)
end
end