I have a script for a crystal that when touched by the player it slowly turns the player into the crystal. It works up until changing the material.
local debounce = false
local colorChange = {
{'Head', 'Mid Gray', 'Granite'};
{'Torso', 'Mid Gray', 'Granite'};
{'Left Arm', 'Mid Gray', 'Granite'};
{'Right Arm', 'Mid Gray', 'Granite'};
{'Left Leg', 'Mid Gray', 'Granite'};
{'Right Leg', 'Mid Gray', 'Granite'};
}
script.Parent.Touched:Connect(function (hit)
if debounce == true then return end
debounce = true
wait(2)
local humanoid = hit.Parent:FindFirstChild('Humanoid')
if humanoid then
for _,v in pairs(colorChange) do
humanoid.Parent[v[1]].BrickColor = BrickColor.new(v[2])
humanoid.Parent[v[1]].Material = Enum.Material(v[3])
wait(0.3)
end
wait(3)
debounce = false
else
debounce = false
end
end)
The output says:
Workspace.SCPs.SCP-409.Contagion [New]:20: attempt to call field 'Material' (a userdata value)
What does this mean and how do I fix it?

1 comment
Thank you!