Skin Instantly Turns Blue

Hello! I am currently making a freezer mechanic, where once you step in the freezer, your character slowly starts turning blue. However, my skin instantly turns blue! There is no transition or anything.

I have no idea why this is happening, and would really appreciate it if someone could help me!

-- timeElapsed on the following line would be the duration for which they were in the freezer or began freezing
local TIME_TO_FREEZE = 20 -- say it takes 20 seconds for them to fully freeze
local FROZEN_COLOUR = Color3.new(0.0313725, 0.662745, 1) -- the colour the player will be when they are fully frozen

local timeElapsed = 0
local isFreezing = false

local function updateColour(plr)
	-- now to get the colour for each body part:
	local head = plr.Character:FindFirstChild('Head')
	local ra = plr.Character:FindFirstChild('Right Arm')
	local la = plr.Character:FindFirstChild('Left Arm')
	local rl = plr.Character:FindFirstChild('Right Leg')
	local ll = plr.Character:FindFirstChild('Left Leg')
	local t = plr.Character:FindFirstChild('Torso')
	local colourInterpolated = head.Color:Lerp(FROZEN_COLOUR, math.clamp(timeElapsed / TIME_TO_FREEZE, 0, 1))
	local colourInterpolated1 = ra.Color:Lerp(FROZEN_COLOUR, math.clamp(timeElapsed / TIME_TO_FREEZE, 0, 1))
	local colourInterpolated2 = la.Color:Lerp(FROZEN_COLOUR, math.clamp(timeElapsed / TIME_TO_FREEZE, 0, 1))
	local colourInterpolated3 = rl.Color:Lerp(FROZEN_COLOUR, math.clamp(timeElapsed / TIME_TO_FREEZE, 0, 1))
	local colourInterpolated4 = ll.Color:Lerp(FROZEN_COLOUR, math.clamp(timeElapsed / TIME_TO_FREEZE, 0, 1))
	local colourInterpolated5 = t.Color:Lerp(FROZEN_COLOUR, math.clamp(timeElapsed / TIME_TO_FREEZE, 0, 1))
	head.Color = colourInterpolated
	ra.Color = colourInterpolated1
	la.Color = colourInterpolated2
	rl.Color = colourInterpolated3
	ll.Color = colourInterpolated4
	t.Color = colourInterpolated5
	-- assign colourInterpolated to the rest of the body parts
end

script.Parent.Door.ClickDetector.MouseClick:Connect(function(plr)
	isFreezing = not isFreezing
	if isFreezing then
		while isFreezing do
			timeElapsed += task.wait()
			updateColour(plr)
		end
	else
		timeElapsed = 0
		updateColour(plr)
	end
end)

Please use Tween Service to do this.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.