So, I want to make when attribute is set to true, I want to create a highlight that the whole server can see it.
However, I want to use TweenService so it looks better. But, I feel like it too slow when you change the attribute fast. I only want to create highlight when IFrame is true, however, when I try destroy it when it false. It also shows the following:
I want to use it globally but roblox appear to be dumb:
How can I solve this?
The following script runs when attribute changes:
local replicatedStorage = game:GetService("ReplicatedStorage")
local tweenService = game:GetService("TweenService")
local remote = replicatedStorage.Remotes:WaitForChild("AttributeChanged")
remote.OnServerEvent:Connect(function(player, character)
if character:GetAttribute("IFrame") == true then
highlight = Instance.new("Highlight", character)
highlight.Name = "IFrameHighlight"
highlight.DepthMode = Enum.HighlightDepthMode.Occluded
highlight.FillColor = Color3.fromRGB(255, 255, 255)
highlight.OutlineColor = Color3.fromRGB(255, 255, 255)
highlight.FillTransparency = 1
highlight.OutlineTransparency = 1
tweenService:Create(highlight, TweenInfo.new(1), {FillTransparency = 0.75}):Play()
tweenService:Create(highlight, TweenInfo.new(1), {OutlineTransparency = 0}):Play()
elseif character:GetAttribute("IFrame") == false and highlight then
tweenService:Create(highlight, TweenInfo.new(1), {FillTransparency = 1}):Play()
tweenService:Create(highlight, TweenInfo.new(1), {OutlineTransparency = 1}):Play()
task.wait(1)
highlight:Destroy()
end
end)