Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How do I tween a numerical value?

I'm trying to increase the range of a PointLight by tweening it, however I'm not sure how I should be creating the Tween. Is it TweenService:Create(PointLight, TweenInfo.new(5),{Range = 0}) or TweenService:Create(PointLight.Range, TweenInfo.new(5),{Number = 0}), or something completely different?

Thanks in advance.

3 answers

You could use a for loop to rapidly change a number

local start = 10
local goal = 70
local increment = 1
for i = start,goal,increment do
	print(i)
	wait(0.1)
	--This will print from 10 to 70 every 0.1 seconds
end

3 comments

0

not what's he asking, -1

0

You sure?

0

I used to loop, however it doesn't look as smooth as tweening.

You can use TweenService to tween a value Instance like normal (for variable...idk) and...... For example

local ts = game:GetService("TweenService")
local goal = {}

goal.Value = 0 -- Start Number
goal.Value = 10 -- uuhh End ?
local tweeninfo = TweenInfo.new(5) -- Seconds
local twe = ts:Create(workspace.Value -- Value Instance
,tweeninfo,goal) -- CREATE
wait(5) -- Let the script relax for 5 seconds
twe:Play() -- P l a y 

Yes, hope that helped

This discussion is preserved as it was. New answers, comments, and votes are closed.