Why Won't My Torso Color Change? {Slider}

Basically, I made three sliders one for R, G, and B. The sliders work fine but when it comes to the color actually changing, it doesn’t work.

--Color-Change Code:

local RColor = script.Parent.RedBar.SliderValue.Text
local GColor = script.Parent.GreenBar.SliderValue.Text
local BColor = script.Parent.BlueBar.SliderValue.Text

local player = game.Players.LocalPlayer
repeat wait() until player.Character
local BC = player.Character:WaitForChild("Body Colors")

BC.TorsoColor3 = Color3.fromRGB(RColor,GColor,BColor)
--Slider Code (1 of 3 sliders)

local UIS = game:GetService("UserInputService")

local sliderFrame = script.Parent
local sliderButton = sliderFrame.Slider
local sliderDisplay = sliderFrame.SliderValue
local sliderDragging = false

sliderButton.MouseButton1Down:Connect(function()
	sliderDragging = true
end)

UIS.InputEnded:Connect(function(input)
	if input.UserInputType == Enum.UserInputType.MouseButton1 then
		sliderDragging = false
	end
end)

UIS.InputChanged:Connect(function(input)
	if input.UserInputType == Enum.UserInputType.MouseMovement then
		if sliderDragging == true then
			local mouseLoc = UIS:GetMouseLocation()
			local abs_size = sliderFrame.AbsoluteSize
			local abs_pos = sliderFrame.AbsolutePosition
			local max = abs_pos.X + (abs_size.X * 1)
			local min = abs_pos.X - (abs_size.X * 0)
			local percentage = math.clamp((mouseLoc.X - min)/(max - min), 0, 1)
			sliderButton.Position = UDim2.new(percentage,0,0.5,0.5)
					sliderDisplay.Text = math.round(percentage * 255)
					
				end
			end
end)

Video of My problem:

If anyone could help, it would be very appreciated, thank you.

1 Like

in the color-change script youre only changing the color once when the players character loads in, put that script inside a loop or check when the sliders position is changed

2 Likes

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