Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
2

How do I tween a numerical value?

Asked by 4 years ago

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

Log in to vote
1
Answered by
Fifkee 2017 Community Moderator Moderation Voter
4 years ago

The former is correct.

0
Thanks. ResDXsention 108 — 4y
Ad
Log in to vote
-1
Answered by 4 years ago
Edited 4 years ago

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
0
not what's he asking, -1 DeceptiveCaster 3761 — 4y
0
You sure? laurenbtd5 379 — 4y
0
I used to loop, however it doesn't look as smooth as tweening. ResDXsention 108 — 4y
Log in to vote
-1
Answered by 4 years ago
Edited 4 years ago

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

Answer this question