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

Why is TweenService not working with StringValues?

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.]

3 comments

0

What is TweenInfo.new(1)?

0

Speed at which the tween plays on

0

Could you please provide the Console log?

1 answer

✓ Accepted answer

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

2 comments

0

That's what I meant by speed. I usually forget to put the :Play()

0

ah i see

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