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

Why is TweenService not working with StringValues?

Asked by
xEiffel 280 Moderation Voter
5 years ago

So I recently wanted to add an effect on my gui where it would make a red fade in and out when hitting a certain number, but the tween is completely not working, I've done some debugging and its running the if statement perfectly fine. Here's the code in a LocalScript in ScreenGui and the value that's detected is a 'String Value'

local replicated_storage = game:GetService("ReplicatedStorage")
local tween_service = game:GetService("TweenService")
local dictionary = replicated_storage:WaitForChild("Dictionary")
local indexStatus = dictionary:WaitForChild("IndexStatus")
local gui = script.Parent:WaitForChild("ScreenGui")

indexStatus.Timer.Changed:Connect(function(new)
    gui.Timer.Text = new
    script.Parent:WaitForChild("Timer"):Play()
    tween_service:Create(gui.Timer, TweenInfo.new(1), {TextColor3 = Color3.fromRGB(255, 49, 49)})
    spawn(function()
        wait(0.65)
        tween_service:Create(gui.Timer, TweenInfo.new(1), {TextColor3 = Color3.fromRGB(255, 255, 255)})
    end)
end)

Thanks for reading.

[I did hear about it not working for IntValues when the new engine came out but I'm unsure if its the same with StringValues.]

0
What is TweenInfo.new(1)? User#19524 175 — 5y
0
Speed at which the tween plays on xEiffel 280 — 5y
0
Could you please provide the Console log? CPF2 406 — 5y

1 answer

Log in to vote
1
Answered by 5 years ago

you dont just create a tween and expect it to work, you must play it too

local tween_service = game:GetService("TweenService")
local dict = {Position=Vector3.new(20,578,109)}
local info = TweenInfo.new(1)

local tween = tween_service:Create(script.Parent,info,dict)
tween:Play() -- note that a wait(1) has to be put after if you need the tween to delay the script cuz tween:Play() does not yeild

p.s. the the first number in tweeninfo does not define the speed, it defines how long the tween takes to reach its goal in seconds

0
That's what I meant by speed. I usually forget to put the :Play() xEiffel 280 — 5y
0
ah i see fanofpixels 718 — 5y
Ad

Answer this question