That’s alright!
I’ll try and get somewhere with it myself.
That’s alright!
I’ll try and get somewhere with it myself.
I wish you the best of luck, if there is anything else I can help with. Id be more than happy to do so!
That’s what I was stuck on, I don’t think you can tween a beam sadly.
I made it a ColorSequence.
local tween = TweenService:Create(beam, TweenInfo.new(0.3), ColorSequence.new(lastColor))
But it says it still needs a table, even though I made one?
Referring to this, I found an efficient Dev forum post that actually works.
Using Lerp and not tween.
Scratch that post, I used the lerp instead, but I assume I didn’t do it right, cause it doesn’t fade, it just goes to black immediately.
local beam = game.Workspace.Spotlights.Spotlight1.Arm.Head.Lens.AttG.Beam
local colour = beam.Color.Keypoints[1].Value
local Time = 0.3
game.ReplicatedStorage.SpotlightStart.OnServerEvent:Connect(function(player, beam)
beam.Color = ColorSequence.new(Color3.fromRGB(255,255,255),Color3.fromRGB(255,255,255))
end)
game.ReplicatedStorage.SpotlightStop.OnServerEvent:Connect(function(player, beam)
for i = 0, 1, wait() / Time do
beam.Color = ColorSequence.new(colour:lerp(Color3.new(0,0,0), i))
wait()
end
end)
Now that I know this semi works, ill work on it again in a bit, ill reply once im finished.
The script properly worked for me, thats weird how it didn’t for you.
robloxapp-20230105-0226407.wmv (482.0 KB)
Set the time to 1
My computer (iMac) can’t open that file sadly, haha.
oh lol, let me make it into a mp4 for you really quick.
May I see the script?
I may be able to modify it in terms of my system.
I used the same script just change the time to .5 or 1
Not changing the result whether I use .5 or 1
It’s probably something wrong with something outside of the script.
Thats weird it should’ve changed it.
Thats probably something / another script altering it.
I’m not sure if it should be doing this…
When I click, it does print “on”
But releasing prints a lot of “off”
If you still prefer to use TweenService for the easing styles, do this (heavy edit from latest code posted by @SuguruDev:
local beam = game.Workspace.Spotlights.Spotlight1.Arm.Head.Lens.AttG.Beam
local colour = beam.Color.Keypoints[1].Value
local Time = 0.3
local offColor, onColor = Color3.new(0, 0, 0), Color3.new(1, 1, 1) -- Set colors here.
local proxyNumber = Instance.new("NumberValue") -- A NumberValue for us to tween.
local proxyNumberOffAnimation = game:GetService("TweenService"):Create(
proxyNumber,
TweenInfo.new(1, Enum.EasingStyle.Linear, Enum.EasingDirection.Out),
{Value = 0}
)
proxyNumber.Changed:Connect(function(value : number) -- Tweening a NumberValue actually fires .Changed every frame.
beam.Color = ColorSequence.new(
if value < 0.0001 then -- Negligible darkness.
offColor
elseif value > 0.9999 then -- Negligible brightness.
onColor
else
offColor:Lerp(onColor, math.clamp(value, 0, 1)) -- math.clamp ensures that the value is between 0 and 1.
)
end)
game.ReplicatedStorage.SpotlightStart.OnServerEvent:Connect(function(player, beam)
if proxyNumberOffAnimation.PlaybackState == Enum.PlaybackState.Playing then
proxyNumberOffAnimation:Cancel()
end
proxyNumber.Value = 1
end)
game.ReplicatedStorage.SpotlightStop.OnServerEvent:Connect(function(player, beam)
proxyNumberOffAnimation:Play()
end)
Should “NumberValue” be put as a nickname or an actual value?
Instance.new("NumberValue")
creates a new NumberValue item.