I need to use this click detector locally

So I was testing my click detector hover over effect, and I realized that it shows up for all players, not just me. I tried just converting it to a local script, this didn’t work.

local tweens = game:GetService("TweenService")
local tweeninfo = TweenInfo.new(0.2)
local tween2 = tweens:Create(script.Parent.Parent.Highlight, tweeninfo,  {FillTransparency = 1, OutlineTransparency = 1})
local tween = tweens:Create(script.Parent.Parent.Highlight, tweeninfo,  {FillTransparency = 0.5, OutlineTransparency = 0.5})

script.Parent.MouseHoverEnter:Connect(function()
	tween:Play()
end)

script.Parent.MouseHoverLeave:Connect(function()
	tween2:Play()
end)

Thanks!

1 Like

LocalScripts can only run on objects that are mainly client-sided only, if you’d want to make this work locally as you stated place the LocalScript within these places:

The only difference is that you’ll have to reference your ClickDetector within the workspace through workspace.Part.ClickDetector to re-obtain it

local TS = game:GetService("TweenService")
local Part = workspace:WaitForChild("Part")
local CD = Part:WaitForChild("ClickDetector")
-- Not sure where Highlight is, you'll have to reference that yourself

local tweeninfo = TweenInfo.new(0.2)
local tween2 = TS:Create(Part.Parent.Highlight, tweeninfo,  {FillTransparency = 1, OutlineTransparency = 1})
local tween = TS:Create(Part.Parent.Highlight, tweeninfo,  {FillTransparency = 0.5, OutlineTransparency = 0.5})

CD.MouseHoverEnter:Connect(function()
	tween:Play()
end)

CD.MouseHoverLeave:Connect(function()
	tween2:Play()
end)
3 Likes

Oh my god I cannot believe how stupid I am, I’m not even new to studio I just somehow didn’t even think of just putting it in playerscripts, thank you for this :sob:

Edit: I’ll try it and mark yours as the answer if it works.

2 Likes

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