So I made this script where it copies the HeadColor3 Value of the BodyColors to a Color3 Value I made. So I want the player’s body color to change to blue if their humanoid state is Swimming. But if the State is Landed then it makes the body colors to their default. So I am saving the HeadColor3 Value to a Color3Value then use the Color3Value to change the color to their normal saved. But after the player landed their body color is Pure Black. Like (0,0,0). This is my script:
local Humanoid = script.Parent:WaitForChild("Humanoid")
Humanoid.StateChanged:Connect(function(oldState, newState)
if Humanoid:GetState() == Enum.HumanoidStateType.Swimming then
print("swimming")
script.Infected.Value = true
end
end)
Humanoid.StateChanged:Connect(function(oldState, newState)
if Humanoid:GetState() == Enum.HumanoidStateType.Landed then
print("landed")
script.Infected.Value = false
end
end)
local SavedValue = script:WaitForChild("SavedColor")
local BColor = script.Parent:WaitForChild("Body Colors")
local SavedColor = BColor.HeadColor3
local IValue = script.Infected
SavedValue.Value = Color3.value(SavedColor)
IValue.Changed:Connect(function()
if IValue.Value == true then
BColor.HeadColor3 = Color3.new(0.145098, 0.823529, 0.972549)
BColor.TorsoColor3 = Color3.new(0.145098, 0.823529, 0.972549)
BColor.LeftArmColor3 = Color3.new(0.145098, 0.823529, 0.972549)
BColor.RightArmColor3 = Color3.new(0.145098, 0.823529, 0.972549)
BColor.LeftLegColor3 = Color3.new(0.145098, 0.823529, 0.972549)
BColor.RightLegColor3 = Color3.new(0.145098, 0.823529, 0.972549)
else if IValue.Value == false then
BColor.HeadColor3 = Color3.new(SavedColor)
BColor.TorsoColor3 = Color3.new(SavedColor)
BColor.LeftArmColor3 = Color3.new(SavedColor)
BColor.RightArmColor3 = Color3.new(SavedColor)
BColor.LeftLegColor3 = Color3.new(SavedColor)
BColor.RightLegColor3 = Color3.new(SavedColor)
end
end
end)