Highlight Cube only for client

Hello guys, I just started learning lua again and I tried making things just to test myself. One thing I wanted to make was that when a player hovers over a block it gets a highlight around it. I got the block made and the “frame” and I wanted to use ClickDetector.MouseHoverEnter to make it visibile and ClickDetector.MouseHoverLeave to make it disappear. The Problem is that I don’t know how to make it so the “Frame” gets visible only for the player that hovers over it. Any help?

Here is some client code that can select whatever part your mouse is on:


local plr = game.Players.LocalPlayer

local mouse = plr:GetMouse()

local highLight = Instance.new("Highlight")

mouse.Move:Connect(function()
	local hover = mouse.Target
	if hover:IsA("Part") then
		highLight.Parent = hover
		highLight.Adornee = hover
	end
end)
1 Like

Create a LocalScript in StarterPlayerScripts and name it whatever. Be sure to have the BillboardGUI in the part.

local Part = workspace.Part
local clickDetector = Part.ClickDetector

clickDetector.MouseHoverEnter:Connect(function()
	local Frame = Part.BillboardGui.Frame --LOCATION
	Frame.Visible = true
end)

clickDetector.MouseHoverLeave:Connect(function()
	local Frame = Part.BillboardGui.Frame --LOCATION
	Frame.Visible = false
end)
1 Like