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
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?
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