I want to tween this Spotlight’s Brightness as a Fade in and Fade off, pretty simple.
as its turned On and Off by the player’s keyboard in a Local Script, i have to replicate it for other players to see it perfectly, since i heard about Replicating things to Server being a bad move for VFX, i wanted to do it by replicating it to all Clients only.
i’ve tried reading posts about FireAllClients, but it seems they aren’t really context friendly with what i am trying to achieve.
Here’s the LocalScript:
wait()
local spotlight = game.Workspace.LIGHTS.SPOTLIGHT.acespot
local tweenservice = game:GetService('TweenService')
local uis = game:GetService("UserInputService")
local tweenInfo = TweenInfo.new(0.3)
wait()
function One(input,isTyping)
if isTyping then return end
if input.KeyCode == Enum.KeyCode.One then
script.Parent.Text = "Turn Off"
for _, obj in pairs(spotlight:GetDescendants()) do
if obj:IsA("SpotLight") then
obj.Enabled = true
local goal = {}
goal.Brightness = 3
local tweenFadeOn = tweenservice:Create(obj, tweenInfo, goal)
tweenFadeOn:Play()
end
end
end
end
function Two(input,isTyping)
if input.KeyCode == Enum.KeyCode.One then
script.Parent.Text = "Ace Spot"
for _, obj in pairs(spotlight:GetDescendants()) do
if obj:IsA("SpotLight") then
local goal = {}
goal.Brightness = 0
local tweenFadeOff = tweenservice:Create(obj, tweenInfo, goal)
tweenFadeOff:Play()
end
end
end
end
uis.InputBegan:Connect(One)
uis.InputEnded:Connect(Two)
(i used a for loop in case i want to use Multiple spotlights at once.)