Why is this outline not working?

heya, so I am working on an outline script where, and everything works great except that when I click the part when the outline is green, it turns off, but doesn’t turn the outline to blue
code:

local mouse = game.Players.LocalPlayer:GetMouse()
local model = game.Workspace.Tire --replace with the model you want hilighted


model.ClickDetector.MouseHoverEnter:Connect(function()
		model.Highlight.OutlineTransparency = 0
end)

model.ClickDetector.MouseHoverLeave:Connect(function()
	if  model.Highlight.OutlineColor ~= Color3.fromRGB(0, 255, 0)then
		model.Highlight.OutlineTransparency = 1
		end
end)

model.ClickDetector.MouseClick:Connect(function()
	if model.Highlight.OutlineColor == Color3.fromRGB(0, 255, 0)then
		model.Highlight.OutlineColor = Color3.fromRGB(0, 0, 255)
		model.Highlight.OutlineTransparency = 1
	end
	if model.Highlight.OutlineColor ~= Color3.fromRGB(0, 255, 0)then
		model.Highlight.OutlineColor = Color3.fromRGB(0, 255, 0)
	end
end)

video of what happens:
robloxapp-20240505-0917167.wmv (1020.7 KB)

This runs both “if” statements, so as the first one changes the colour the second turns it back immediately.
You just need to change it to “elseif” in the middle (instead of the end and second if
Also, the first if statement is turning the transparency to 1, so you can remove that line.

i agree with this other than that I can get rid of the first if statement. that actually makes the outline visible, and if the outline isn’t visible none of the other code will show

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