Localized property changes

I’ve been struggling with highlighting interactable object, when you hover your mouse over them, the script play both globally and on player’s client, the scripts are bellow:

local function onHoverEnter(player)
	ColorShift:Play()
	cPart.BrickColor = BrickColor.White()
end



local function onHoverLeave(player)
	cPart.BrickColor = BrickColor.Gray()
end

cDetector.MouseHoverEnter:connect(HoverOn) -- Highlighting
cDetector.MouseHoverLeave:connect(HoverOff)

The above is a chunk of my code and I want to find a way to make it visible to the player who hover their mouse over it.

If you want to make it only client-sided, you could cast a ray every render step and then change the colour based on whether the part meets certain criteria.

--This is just an example , I made this quickly (ClientScript)
local RunService = Game:GetService("RunService")
local Players = Game:GetService("Players")

local player = Players.LocalPlayer
local Mouse = player:GetMouse()

local function onRenderStep()
      if Mouse.Target then
      -- change color
      end
end

RunService.RenderStepped:Connect(onRenderStep)

1 Like

I forgot to show the video.

Thank you for your respond, but I can’t seem to get the script to work, I inserted it both in a Local script, and a normal script, none seems to work

if you have this only a localscript it should only work on the client, where is the script located?

I haven’t located the script yet, I left it in Workspace.

So, the script became:

function updatePos()
local target = mouse.Target
	if target and target:FindFirstChild("TagHL") then
									-- Script here
end

mouse.Move:Connect(updatePos)

Am I doing it right?

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