New Script

Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 3

local Players = game:GetService("Players")

local UserInputService = game:GetService("UserInputService")

local originalColors = {}

-- Function to change character colors based on RGB values


local function setCharacterColors(character, r, g, b)
local selectedColor = Color3.fromRGB(r, g, b)

for _, part in ipairs(character:GetChildren()) do


if part:IsA("BasePart") or part:IsA("MeshPart") then
originalColors[character] = originalColors[character] or {}
originalColors[character][part] = {Color = part.Color}
part.Color = selectedColor
elseif part:IsA("Accessory") and part:FindFirstChild("Handle") then
originalColors[character] = originalColors[character] or {}
originalColors[character][part.Handle] = {Color = part.Handle.Color}
part.Handle.Color = selectedColor
end
end
end

-- Function to reset colors to the original


local function resetCharacterColors(character)
if originalColors[character] then
for part, colorData in pairs(originalColors[character]) do
if part and colorData and colorData.Color then
part.Color = colorData.Color
end
end
originalColors[character] = nil
end
end

-- Create UI elements for RGB sliders


local screenGui = Instance.new("ScreenGui")
screenGui.Parent = game.Players.LocalPlayer:WaitForChild("PlayerGui")

-- Function to create an individual slider UI


local function createSlider(colorName, maxColorValue, positionY, callbackFunction)
local sliderFrame = Instance.new("Frame")
sliderFrame.Size = UDim2.new(0.8, 0, 0.1, 0)
sliderFrame.Position = UDim2.new(0.1, 0, positionY, 0)
sliderFrame.BackgroundColor3 = Color3.fromRGB(255, 255, 255)
sliderFrame.Parent = screenGui

local sliderLabel = Instance.new("TextLabel")


sliderLabel.Size = UDim2.new(0.2, 0, 1, 0)
sliderLabel.Text = colorName
sliderLabel.TextColor3 = Color3.fromRGB(0, 0, 0)
sliderLabel.BackgroundTransparency = 1
sliderLabel.Parent = sliderFrame

local slideFrame = Instance.new("Frame")


slideFrame.Size = UDim2.new(0.5, 0, 1, 0)
slideFrame.Position = UDim2.new(0.3, 0, 0, 0)
slideFrame.BackgroundColor3 = Color3.fromRGB(0, 0, 0)
slideFrame.Parent = sliderFrame
-- Add draggable functionality to the slider
local dragging = false
sliderFrame.InputBegan:Connect(function(input)
if input.UserInputType == Enum.UserInputType.MouseButton1 or
input.UserInputType == Enum.UserInputType.Touch then
dragging = true
end
end)

sliderFrame.InputEnded:Connect(function(input)
if input.UserInputType == Enum.UserInputType.MouseButton1 or
input.UserInputType == Enum.UserInputType.Touch then
dragging = false
end
end)

UserInputService.InputChanged:Connect(function(input)
if dragging and (input.UserInputType == Enum.UserInputType.MouseMovement or
input.UserInputType == Enum.UserInputType.Touch) then
local position
if input.UserInputType == Enum.UserInputType.MouseMovement then
-- Calculate position for mouse input
position = (input.Position.X - sliderFrame.AbsolutePosition.X) /
sliderFrame.AbsoluteSize.X
else
-- Calculate position for touch input
position = (input.Position.X - sliderFrame.AbsolutePosition.X) /
sliderFrame.AbsoluteSize.X
end

-- Clamp position between 0 and 1


local pos = math.clamp(position, 0, 1)
slideFrame.Size = UDim2.new(pos, 0, 1, 0)

-- Call the callback with the new slider position (scaled to 0-255)
callbackFunction(math.floor(pos * maxColorValue))
end
end)
end

-- Create RGB sliders


local rValue = 0
local gValue = 0
local bValue = 0

local function updateColors()


local character = Players.LocalPlayer.Character
if character then
setCharacterColors(character, rValue, gValue, bValue)
end
end

createSlider("Red", 255, 0.1, function(value)


rValue = value
updateColors()
end)

createSlider("Green", 255, 0.3, function(value)


gValue = value
updateColors()
end)

createSlider("Blue", 255, 0.5, function(value)


bValue = value
updateColors()
end)

-- Reset colors on respawn


Players.LocalPlayer.CharacterAdded:Connect(function(character)
-- Reset the character’s colors
character:WaitForChild("Humanoid").Died:Connect(function()
resetCharacterColors(character)
end)
end)

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy