Using a color in script but its choosing a different one

I’ve been working on trying to change the color of a part when you touch it and after it changes back, but the part turns into a completely different color. I’ve tried to use different colors that seemed similar to it but it still came out completely different from the color I chose. Once I input a variable for the color of my part and it ended with it turning black.

local debounce = false
local color = game.Workspace.Blobs.Blob.Color
for i, v in pairs(game.Workspace.Blobs:GetChildren()) do
v.Touched:Connect(function()
v.Color = Color3.new(0.901732, 0.672251, 0.223148)
wait(1)
v.Color = Color3.new(color)
end)
v.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild(“Humanoid”) and debounce == false then
debounce = true
hit.Parent.Humanoid.Sit = true
hit.Parent.Humanoid:TakeDamage(25)
wait(1)
debounce = false
end
end)
end

1 Like

Is the color variable a value object? >>> local color = game.Workspace.Blobs.Blob.Color

Cause if so, you wanna add ‘.Value’ next to it like this: game.Workspace.Blobs.Blob.Color.Value

Value not valid member of color3 it says in output

Can I ask exactly what ‘local color = game.Workspavce.Blobs.Blob.Color’ is?

Part of an obby where player gets hit and I just wanna add more to the obby so I make some color changes.

Oh sorry I was confused, I forgot that Color was a property. My bad, alright I’m gonna try to replicate the script in a seperate workspace real quick.

In the meantime, are there any other scripts that interfere with the part’s color or is this the only one?

This is the only script. Its weird too because it goes full black (0,0,0).

Ok so let me ask just to make sure. You want to make it so that when you touch the blob it changes color but makes it switch back to its past color after 1 second?

Yeah(I have to post extra characters)

Ok so with this script I was able to not make that black color glitch from happening. I did this by storing the color values the part would switch into with variables so that there would be no way the script gets confused with the changing color property from the part that the previous script was referencing. If you can’t use this script for some other reason, please let me know, I’ll try my best to make another rendition under your provided restrictions.

local debounce = false
local normalColor = Color3.fromRGB(163, 162, 165)
local changeInColor = Color3.new(0.901732, 0.672251, 0.223148)


for i, v in pairs(game.Workspace.Blobs:GetChildren()) do
	
	v.Touched:Connect(function(hit)
		
		v.Color = changeInColor
		task.wait(1)
		
		v.Color = normalColor
		
		if hit.Parent:FindFirstChild('Humanoid') and debounce == false then
			debounce = true
			hit.Parent.Humanoid.Sit = true
			hit.Parent.Humanoid:TakeDamage(25)
			task.wait(1)
			debounce = false
		end
	end)
	
end
1 Like

Thank you, it works. (CHARACTER PLACEHOLDER)

1 Like

Glad I could help, have a good day. Good luck with your endeavors!

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