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

How to do onTouch Color Tweening?

Asked by 4 years ago

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

Log in to vote
0
Answered by 4 years ago
Edited 4 years ago

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)

0
Thank you so much! It worked for me and helped me with my issue! ggAmazingMan 32 — 4y
Ad
Log in to vote
0
Answered by
JesseSong 3916 Moderation Voter Community Moderator
4 years ago
Edited 4 years ago

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

1
If TweenService supports it, there is such a thing as <Property> Tweening. Therefore, Color Tweening is a thing. Ensure your sources are optimal and accurate before making assumptions. Ziffixture 6913 — 4y
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. Ziffixture 6913 — 4y

Answer this question