Highlighting issue

I tried this before but just resorted to making a new highlight everytime when that didn’t work but ig that doesnt work either

Then I’m certain the issue is with multiplying the range value.

Ah my bad I see, I kinda think that its not a limitation but actually a bug. It seems like the highlights don’t update due to performance patches. I’ll try to reproduce this and fix it .

So basically try * 7.1?

I need characters

Do you mind sending the place the issue is happening on? So I can quickly reproduce this and get it fixed? You don’t have to if you don’t want to but it would be much better if you did

Sure, lemme just try to remember how to send places rq

No, multiply by the width of a tile and add a threshold like 0.1.

ex. range = range * 7 + 0.1

untitledgame(1).rbxl (79.0 KB)

tried this rq, same result once trying a second movement

Did you set the adornment to the model properly?
You should be able to parent the highlight wherever you want as long as it’s adornee property is set.

Also, highlights have been known to be glitchy, they behave awfully weird for me as well at times.
It sometimes clips through geometry even though it’s supposed to be fully occluded and has it’s occlusion settings set correctly.

Yep, I parent it to the Selected model and adorn it just to be sure, and yea theres a chance this can’t really be fixed unless roblox does something about highlights but I’d rather try to find a workaround than go with changing them all to a solid color and back

1 Like

Strange behavior! But I found that rewriting:

function removeHighlight()
	for i, v in map.Selected:GetChildren() do
		if v:IsA("BasePart") then
			v.Parent = tiles
		else
			v:Destroy()
		end
	end

	action = nil
	class = nil
	renewHighlight(false)
end

to:

function removeHighlight()
	renewHighlight(false)
	
	for i, v in map.Selected:GetChildren() do
		if v:IsA("BasePart") then
			v.Parent = tiles
		else
			v:Destroy()
		end
	end

	action = nil
	class = nil
end

fixed the issue.

I used this and it didn’t seem to work, did you use the place I sent when testing?

I did. Here’s a video of what happens on my side:

Hey there! Thanks for sharing the place, after reproducing the issue I found the cause and fixed it!

Here is the fixed function at first:

function renewHighlight(enabled)
	RunService.Heartbeat:Wait()
	if map.Selected:FindFirstChildWhichIsA("Highlight") then
		map.Selected.Highlight.Adornee = nil
		map.Selected.Highlight.Enabled = false
		--map.Selected.Highlight:Destroy()
		-- this line caused the error

		print("this is a print")
	end
	
	-- and this line too but I fixed it
	local highlight = map.Selected:FindFirstChildWhichIsA("Highlight") or Instance.new("Highlight")
	highlight.FillColor = Color3.fromRGB(0, 16, 255)
	highlight.OutlineColor = Color3.fromRGB(106, 144, 237)
	highlight.DepthMode = Enum.HighlightDepthMode.Occluded

	highlight.Enabled = enabled
	highlight.Adornee = map.Selected
	highlight.Parent = map.Selected
	task.defer(function()
		highlight.Enabled = false
		highlight.Adornee = nil
		RunService.Heartbeat:Wait()
		highlight.Enabled = enabled
		highlight.Adornee = map.Selected
	end)
end

Quick explanation on what caused the bug:
For whatever reason, roblox engine or whatever kept a few of the highlights even after the deletion, so I tried to fix it by not destroying the highlight, but by keeping it and making sure that it does update with the new tiles.

If the issue is fixed you can mark this as a solution.

Ok I think after later edits something else had bugged it then, just copying the code in the downloadable place and this fixed it!

Can’t thank you enough

This also worked, and thanks for the explanation!

I’d give solution but sadly these posts only allow one

1 Like

Its fine, the other approach that you marked as a solution is better anyways

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.