I’ve created a highlight that only highlights certain objects, in this instance it’s a rock. I parented the highlight to a highlight script and put that in the starter player, because the script is attached to a tool. Whenever I pull out the tool in game my character model also gets highlighted. How would I go about fixing this?
mouse.Idle:Connect(function()
if equipped then-- equipped is a boolean that becomes true whenver the tool is equipped
if not mouse.Target then
script.Highlight.Adornee = nil
return
end
if ColletionService:HasTag(mouse.Target.Parent, "Level1Rock") then
script.Highlight.Adornee = mouse.Target.Parent
return
end
end
script.Highlight.Adornee = nil
end)
You should check if you’re hovering anything relevant, and if so, both enable and set the adornee of the highlight, else, just disable it. I wouldn’t recommend setting the adornee to nil, since that would highlight your character model instead of the latest adornee in case of an error.
--## simplified!
Event:Connect(function()
if Equipped and Target then
if Target:HasTag("Rock") then
Highlight.Enabled = true
Highlight.Adornee = Target
else
Highlight.Enabled = false
end
else
Highlight.Enabled = false
end
end)
Ended up moving the script to starter player, and outside of the tool. Fixed the issue without fixing the issue. The problem was the highlight was in the tool and whenever the tool was equipped the highlight would be technically on the character highlighting the model. Tried using the enabled/disabled method but the model would still be highlighted whenever the rock was hit