Hello there, I have a part that I want the material to be changed from plastic to neon upon contact with the part, and after one second, the material is changed back to plastic. Here's the script I used. The script is located in the part in the workspace.
script.Parent.Touched:Connect(function(hit) if hit.Parent:FindFirstChild("Humanoid") then hit.Material = "Neon" wait(1.0) hit.Material = "Material" end end)
Please help.
This script changed the material to Neon and after 1 second it changes back to Plastic. Instructions: Insert a "Part" into "Workspace" Insert a "Script" into "Part" that's inside "Workspace" and copy and paste or just type what's below.
db = false script.Parent.Touched:Connect(function(hit) if hit.Parent:FindFirstChild("Humanoid")then if db == false then db = true script.Parent.Material = Enum.Material.Neon wait(1) script.Parent.Material = Enum.Material.Plastic db = false end end end)
Although I have not found an answer, this method I used was able to turn the humanoid into the forcefield material. I am pretty sure humanoid figures can't be materialized. Here is my code
local debounce = false script.Parent.Touched:Connect(function(hit) if hit.Parent:FindFirstChild("Humanoid") then for i,v in pairs(hit.Parent:GetDescendants()) do if v:IsA("BasePart") then v.Material = Enum.Material.ForceField end end end end)
You can also use hit.Parent:GetChildren()
but hit.Parent:GetDescendants will go through all objects from top to bottom. I can't give a perfect answer to your problem though, but this is a good step to your goal though