Currently, I’m trying to attach a model to the player’s back (the model is an object inside of the player’s character) and then add a Highlight to a part in the model. For some reason, the highlight also affects the character and the entire model instead of the specific part inside the model. I have already tried setting the Adornee, but it doesn’t do anything.
This is the code I’m using to create and set the parent of the Highlight.
local EquipmentHighlight = script.HighlightEquipment
local EHlClone = EquipmentHighlight:Clone()
EHlClone.Enabled = true
EHlClone.Parent = Bag:FindFirstChild("MainBagPart")
Any help would be much appreciated!
p.s. I already have a half-workaround, I am using a selection box instead, though it doesn’t really work great as it is unable to render on top, and highlights look alot cleaner.
I tried reproducing your situation with just a Dummy and a Part (only the Part has the Highlight) in Studio and unfortunately, I couldn’t get the same thing to happen to me. At least I thought at first.
But then I just played around with the Red Part a bit by removing it and re-inserting it back into the Dummy and then this happened:
I’m still trying to figure how it’d be reversed without just using Studio’s Undo/Redo. It’s something with Roblox’s parenting system though. And trying to figure its connection to your problem which is basically the same.
Does the same behavior occur if you recreate the Highlight directly from your code with Instance.new instead of using an existing one + Instance:Clone?
And what happens when you try using EquipmentHighlight directly without cloning? (although I know for more than 1 use, you’d need a clone anyway, so this attempt doesn’t make much sense beyond that)
Unfortunately Highlight barely has any documentation insight that could help either. I’m going to try reproducing your case through scripts instead of just in studio.
Creating a new instance of the highlight causes it to have the same problematic results of highlighting the entire character, and inserting a highlight without cloning via the explorer interestingly causes it to not work at all.
Did a bunch of stuff only to end up with fruitless results. Is there anything in particular that is unique to the character the Highlight is affecting and the object it’s supposed to affect?
For example, are you working with a custom character in which the Highlight is being incorrectly applied to, stuff like that?
Oh my god, I think I realize why your Highlight is doing this. If you think about the many ways of organizing things, Models actually relate to geometry compared to something like a Folder.
It must be considering the character and your bag model as one single piece of geometry to render the highlight over? Try refactoring your system to use a different container type for the bag (I know this wouldn’t be great when you have to attach + move it though).
If you look at Roblox’s documentation for Models, it mentions something similar too (although Highlights are not mentioned here, it would make sense):
Models are container objects, meaning they group objects together. They are best used to hold collections of BaseParts and have a number of functions that extend their functionality.
Models are intended to represent geometric groupings. If your grouping has no geometric interpretation, for instance a collection of Scripts, use a Folder instead.
You mentioned in your post, you’re trying to highlight a nested Part in a nested Model in the character (the character ITSELF is also a Model!):
Currently, I’m trying to attach a model to the player’s back (the model is an object inside of the player’s character)
That’s how I made this connection.
TLDR:
You either have to change the container for your bag to something else
Potentially move the part of the bag you want to be highlighted out of the nested model
Upon testing, this workaround does indeed work. Although it’s really inconvenient, I guess I’ll just have to live with this.
One thing this doesn’t explain however is why this problem doesn’t happen on one of the other components of my game: drills. Their highlights work in the exact same way of having a highlighted part inside a model and they do not generate this problem. Very strange and annoying inconsistency.
Hm, I understand your original problem is technically already solved, but if you can show me the structure of your drills in the Explorer, I might be able to draw some conclusion out of the inconsistency.
One important detail, are you still parenting the Drill model to the player's Character in your implementation?
If you aren’t parenting the Drill to any upper Model itself (like the character), then the reason why the Drill isn’t affected by the original problem is probably because it’s now just an independent piece of geometry, so its contents can be highlight-rendered separately. For a nested model, it’ll probably try to render the highlight on the topmost Model which is what your bag Model is doing for the character.
BUT…
If you are actually parenting the Drill to another Model like the character, then yeah this is a really weird inconsistency. But Roblox is kinda filled with a bunch of inconsistencies anyway, isn’t it?
I have tried parenting the drill to the thing being drilled from the explorer. Either way, it still doesn’t do the same bug that happens on the character.
I did find a potential hacky solution: it might work if I parent the bag to the workspace, add the highlight, and then re-parent it to the character.
I did find a potential hacky solution: it might work if I parent the bag to the workspace, add the highlight, and then re-parent it to the character.
Does it?
EDIT:
Regardless of what the result is, lets just hope the Highlight system improves in the future. Well, we’d probably have to make feature requests for real changes but that’s out of scope for just this.
reply to your edit:
I’m pretty sure highlighting is new, hence it’s lack of documentation. I’m sure it’s still being worked on and something might change making stuff like this possible in the future. Also again, thanks for helping even past when a solution was found.