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

How to do onTouch Color Tweening?

I would like to ask for a little help.

I wanted to make a Light, that goes from Green To red, and then back to green when touched. I want it to be smooth but I can't really figure out how TweenService works, so I would be glad if someone could help me. Any help is appreciated and I hope someone can help with my question!

2 answers

✓ Accepted answer

This is an edit of @JesseSong 's answer since I tried it and it doesn't work. This would work:

local part = script.Parent

part.Touched:Connect(function(hit)
    local player = game:GetService("Players"):GetPlayerFromCharacter(hit.Parent)

    if player then
		local ts = game:GetService("TweenService")
		local tween = TweenInfo.new(1, Enum.EasingStyle.Bounce, Enum.EasingDirection.Out) 
		local t = ts:Create(part, tween, {Color = Color3.fromRGB(1,255,255)})

		t:Play()
	end
end)

1 comment

0

Thank you so much! It worked for me and helped me with my issue!

The below code should work you may need to edit some stuff in studio. And there is no such thing as color tweening

part.Touched:Connect(function(hit)
    local player = game:GetService("Players"):GetPlayerFromCharacter(hit.Parent)
    if player then
local part = script.Parent
local ts = game:GetService('TweenService')
local tween = TweenInfo.new(1, 'Bounce', 'Out') 
local t = ts:Create(part, tween, {BackgroundColor3 = Color3.new(1,255,255)})

t:Play()
end
end)

If I helped you make sure to accept this answer

2 comments

1

If TweenService supports it, there is such a thing as Tweening. Therefore, Color Tweening is a thing. Ensure your sources are optimal and accurate before making assumptions.

2

This includes multiple betterment practices within this code above that you haven’t supplied. Especially the use of Enum types rather than String casting when defining Easing Direction and Style.

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