How would I make it so that when you sit in a chair, your skin color slowly turns a diffrent color
✓ ANSWER ACCEPTED
How can I cause a color change using an event?
2 answers
✓ Accepted answer
local tweenService = game:GetService("TweenService")
local seat = workspace.Seat
local faces = { --table of face id's. Keep in mind that you have to get these faces from the Toolbox. Faces from the catalog will not work.
5303681402,
5646474823,
275614649
}
seat:GetPropertyChangedSignal("Occupant"):Connect(function() --detects when occupant changes
local humanoid = seat.Occupant
if humanoid then --if player is in the seat then
local character = humanoid.Parent
local randomColor = Color3.fromRGB(math.random(0,255),math.random(0,255),math.random(0,255)) --generate a random color
local tweenInfo = TweenInfo.new( --construct tween info
5, -- Time
Enum.EasingStyle.Linear, -- EasingStyle
Enum.EasingDirection.Out, -- EasingDirection
0, -- RepeatCount (when less than zero the tween will loop indefinitely)
false, -- Reverses (tween will reverse once reaching it's goal)
0 -- DelayTime
)
for _,part in pairs(character:GetChildren()) do --go through all the children of the player's character
if part:IsA("BasePart") then --if the child is a part then
local tween = tweenService:Create( --construct a tween to change colors
part,
tweenInfo,
{
Color = randomColor
}
)
tween:Play() --play the tween
end
if part.Name == "Head" then
local face = part.face --get the player's face in the player's head
local newface = Instance.new("Decal",part)
newface.Name = "face"
newface.Transparency = 1
newface.Texture = "rbxassetid://"..faces[math.random(1,#faces)] --generate a random face
local tween1 = tweenService:Create( --construct a tween to make the old face slowly disappear
face,
tweenInfo,
{
Transparency = 1
}
)
local tween2 = tweenService:Create( --construct to make the new face slowly appear
newface,
tweenInfo,
{
Transparency = 0
}
)
tween1:Play()
tween2:Play()
tween1.Completed:Wait() --wait until the tween that makes the old face disappear to destroy the old face
face:Destroy()
end
end
end
end)
Detect when theres a new Childadded onto the seat and get the player part weld and then get the entire player and tween them to a different color
This discussion is preserved as it was. New answers, comments, and votes are closed.

9 comments
thank you so much! Works Perfectly, I was wondering, if I could make it so it could also slowly replace the face with something? I would guess it is a similar script but im not sure what models to use
Edited my answer to include a bit that changes the face
hey, sry to bother you.... but i put in the code into the seat (replacing the old code) and it didn't work, spent about an hour trying to debug it
Make sure it's a server script
how do i make sure of that? also, do i change the #faces to the number? and are the other spots i need to change
You can see if the script is a server script by looking at the icon. if it's a blank sheet of paper you're good. Tell me what errors you have by pulling up the output in the view tab
with the raw code, it says "seat is not a valid member of Workspace "Workspace"
Change line 2 to local seat = script.Parent
works! thanks!