Transparency Tweening on a SelectionBox

Hi I’m trying to make a SelectionBox SurfaceTransparency tween in and out to create a fading and reappearing effect.

I have been trying to use the tween service to fade the SurfaceTransparency smoothly but I can’t get it to work and it won’t output any errors or warnings.

I have tried looking at the SelectionBox refrence on the Developer Hub but I haven’t had any luck, some extra probably useless information is that the SurfaceTransparency value is a text box not a slider but I’m not sure if that makes a difference since I’m band new to roblox lua.

local tweenService = game:GetService("TweenService")
local box = script.Parent
local tweenInfo =
	1, --Time
	Enum.EasingStyle.Linear, --EasingStyle
	Enum.EasingDirection.Out, --EasingDirection
	9999, --Repeat count
	true, --Reverses if true
	0.2 --Delay time
local tween = tweenService:Create(box, tweenInfo, {SurfaceTransparency=0})
tween:Play() print('run')

It works perfectly for me, make sure you have the SelectionBox.Adornee property set to the Instance you want the selection box to be displayed on.

Also, if you want to loop the tween indefinitely, use
TweenInfo.RepeatCount = -1.

Thank you for the tip.
I found the problem I put the code in a local script :sweat_smile:

1 Like

LocalScripts only run when they are a descendant of the player. So you’d have to put the LocalScript in a place like StarterPlayerScripts or StarterGui.

1 Like