Hey! I want to make my model’s rocks’ material property change to the other part’s material when they are in contact. My script doesn’t work though, it only works when the rock gets touched by the player.
How do i check if a part is touching another, i can’t use :GetTouchingParts since my parts are uncollideable.
local rocks = game.Workspace:WaitForChild(Rocks) -- model
for i, v in pairs(rocks:GetChildren()) do
v.Touched:Connect(function(hit)
if v.Name == "Rock" then
v.Material = hit.Material
end
end)
end
Right now your code basically gets all children of the rocks model and then checks if the child of the model is named “Rock”.
I’m not sure if you want that to happen or if you want to check if the “hit” / the part that touches the child of the model is named rock. In that case I would change your script to:
if hit.Name == "Rock" then
v.Material = hit.Material
end
Hopefully I understood correctly and this helps you, if not please correct me!