Recently, I joined a Roblox experience called “Pet Simulator X”, which is pretty popular at the moment on the whole platform (LOL) and I noticed that they added the feature Highlight across the majority of the models as well as for your character whenever you join:
That said, I am curious how you can achieve this by making a script and where it needs to be created, whether on ServerScriptService or only for the client side (StarterPlayer).
If anyone knows how I can make this goal happen, let me know in the replies!
You can create an instance called “Highlight” in a script
local highlight = Instance.new("Highlight")
highlight.Adornee = something -- what the highlight is applied to
highlight.Parent = something -- you can also parent the highlight to apply it
Yes.
Keep in mind you can only have 31 highlights at one time though. This doesn’t mean the highlight can only affect 31 instances, you just need to group all the parts you need to be highlighted together into a model, and then place a highlight adorned to the model.
I tried seeing if I was able to adorn and parent the Highlight feature whenever a Player joins the game, but it does not seem to appear whatsoever. By the way, the code below that I will show is stored at ServerScriptService:
local Players = game:GetService("Players")
local highlight = Instance.new("Highlight")
Players.PlayerAdded:Connect(function(player)
highlight.Adornee = player
highlight.Parent = player
highlight.FillColor = Color3.new(0, 0, 0)
highlight.FillTransparency = 1
end)
You’re adorning it to the player instead of the character. The player is not a visual thing. You’re also only creating one highlight. There’s no need to set the .Adornee, because it automatically sets it to the model it’s under. Only set the .Adornee if you’re going to move the highlight somewhere else.
Code:
local Players = game:GetService("Players")
Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(character)
local highlight = Instance.new("Highlight")
highlight.FillColor = Color3.new(0, 0, 0)
highlight.FillTransparency = 1
highlight.Parent = character
end)
end)