0% found this document useful (0 votes)
19 views

New Script

Uploaded by

brokensinjustice
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
19 views

New Script

Uploaded by

brokensinjustice
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 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