Why are highlights sometimes not working in my game?

I’m not sure if this is an engine issue or what, but I have this x-ray ability in my game where players can use and it enables or disables highlights, and the thing is some of my players are saying that it isn’t working sometimes and then for other players I ask them if they’ve encountered any bugs and they have said no?

Here is the code, I have a strong feeling this is just an engine issue also I have the highlight inside of a model with all the parts that can be highlighted

Pretty much just focusing on the tween function where it enables or disables lights depending on the task, so basically if either task isn’t Active then no highlight will be enabled, the part the sometimes isnt working for some players is that when it is either task it’s just not working??

local Lighting = game:GetService("Lighting")
local module = {}

local LostItemsStorage = workspace.LostItems
local LostPanels = workspace.LostPanels

local spr = require(game.ReplicatedStorage.spr)

local FindSolarPanels = require(game.ReplicatedStorage.Tasks.FindSolarPanels)
local LostItems = require(game.ReplicatedStorage.Tasks.LostItems)

local function tween(n)
   if FindSolarPanels:IsActive() then
      if n < 0 then
         LostPanels.Highlight.Enabled = true
      else
         LostPanels.Highlight.Enabled = false
      end
   elseif LostItems:IsActive() then
      if n < 0 then
         LostItemsStorage.Highlight.Enabled = true
      else
         LostItemsStorage.Highlight.Enabled = false
      end
   end
   spr.target(Lighting, 10, 7, {
      ExposureCompensation = n
   })
end

function module.Usability(bool)
   if not bool then
      tween(0)
   end
end

function module.InputBegan()
   tween(-5)
end

function module.InputEnded()
   tween(0)
end


return module
1 Like

It could be because highlights have a max limit, which is 31.

2 Likes

Wait max limit what do you mean could you explain further please, because I really need to get this issue fixed

1 Like

For performance, roblox only allows 31 highlights at a time

1 Like

well, well ,well its wonderful you brought up that point but looking at the explorer here for the items, there only 2 being used in each model

image

@iATtaCk_Noobsi Now what is your consensus?

No clue, I haven’t actually used them in studio before so someone else is probably gonna have to help you.

1 Like

Yeah I feel like its an engine bug, but even though you might not be able to help me solve it do you think you could help me come up with a different method of using xray? Like a different way without having to use highlights?

You could use a bill board gui, which can basically show the location of whatever you’re trying to track, just make sure to set AlwaysOnTop as true

1 Like

Wait that’s actually a brilliant idea thanks so much gonna try this!

Highlight objects dont work on mobile devices. this is a bug that is apparently being fixed although its been a issue for a couple years now bug report

1 Like

Using 2 highlights per model seems excessive. You could easily merge them into one model and just use one highlight.

You can also temporarily move players that have their X-Ray turned on into a model with a singular highlight, so you can theoretically control hundreds of players with a single highlight instance. It all depends on your implementation.
I haven’t had any issues with highlights so far. In your case if you use X-ray on just 15 people you would have already reached your limit, not to mention potential other areas of your game that you might be using highlights for but haven’t mentioned.

Also keep in mind Client to Server communications, any highlights your create on the client will not replicate to other users. So highlights might not be properly replicating. If you’re creating highlights on the server disregard this last part.

If the part’s transparency is anything that is not 0, they will not work. have you made sure that nothing is transparent at all?