local Players = game:GetService("Players")
Players.PlayerAdded:Connect(function(plr)
wait(5)
local char = plr.Character
for i,Child in pairs (char:GetChildren()) do
if Child:IsA("MeshPart") then
Child.Color = Color3.fromRGB(112, 69, 255)
Child.Material = 'ForceField'
end
end
for i,Child in pairs (char:GetChildren()) do
if Child:IsA("Accessory") then
local ChildA = Child:FindFirstChildWhichIsA('MeshPart')
ChildA.Color = Color3.fromRGB(112, 69, 255)
ChildA.Material = 'ForceField'
-- char.Head.face.Transparency = 1
end
end
wait(5)
-- do thing
end)
after the wait(5) I want to give the player their colors back and also their proper material, my problem is how to grab the color values that they had before they were changed?
this does explain it better, but my problem is how to do the whole “store the color” code part :I?, doesnt need to be the whole code done, I just want some hints or whatever to at least start somewhere
Players.PlayerAdded:Connect(function(plr)
wait(5)
local char = plr.Character
local SavedColorTable = {}
for i,Child in pairs (char:GetChildren()) do
if Child:IsA("MeshPart") then
SavedColorTable[Child.Name] = Child.Color
Child.Color = Color3.fromRGB(112, 69, 255)
Child.Material = 'ForceField'
end
end
for i,Child in pairs (char:GetChildren()) do
if Child:IsA("Accessory") then
local ChildA = Child:FindFirstChildWhichIsA('MeshPart')
ChildA.Color = Color3.fromRGB(112, 69, 255)
ChildA.Material = 'ForceField'
-- char.Head.face.Transparency = 1
end
end
wait(5)
-- do thing
end)
Printing SavedColorTable will return a table of the limb’s colors.
thanks everybody who replied, the script is finally done! and pretty easy to mess around with too!
local Players = game:GetService("Players")
local function onCharacterAdded(character)
local SavedColorTable = {}
for i,Child in pairs (character:GetChildren()) do
if Child:IsA("BasePart") then
SavedColorTable[Child.Name] = Child.Color
print(SavedColorTable)
end
end
wait(0.01)
for i,Child in pairs (character:GetChildren()) do
if Child:IsA("BasePart") then
Child.Color = Color3.fromRGB(112, 69, 255)
Child.Material = 'ForceField'
end
end
for i,Child in pairs (character:GetChildren()) do
if Child:IsA("Accessory") then
local ChildA = Child:FindFirstChildWhichIsA('MeshPart')
ChildA.Color = Color3.fromRGB(112, 69, 255)
ChildA.Material = 'ForceField'
end
end
wait(3) -- time until it returns to normal
for bodypart, color in pairs (SavedColorTable) do
character[bodypart].Color = color
end
for i,Child in pairs (character:GetChildren()) do
if Child:IsA("BasePart") then
Child.Material = 'Plastic'
end
end
for i,Child in pairs (character:GetChildren()) do
if Child:IsA("Accessory") then
local ChildA = Child:FindFirstChildWhichIsA('MeshPart')
ChildA.Color = Color3.fromRGB(255, 255, 255)
ChildA.Material = 'Plastic'
end
end
end
local function onPlayerAdded(player)
player.CharacterAdded:Connect(onCharacterAdded)
end
Players.PlayerAdded:Connect(onPlayerAdded)