Touch Function + TextureId = Touch to change TextureId

I have a tool where anything you touch with it turns into gold, the only thing missing is being able to change the TextureId of any mesh to 0 so it looks like it’s been turned into good

Image here:
RobloxScreenShot20220818_141239908

bin = script.Parent
local MeshPart = script

function onTouched(part)   
	part.BrickColor = BrickColor.new("Daisy orange")
	part.Material = Enum.Material.Glass
	part.Reflectance = 0.15
	if part:IsA("UnionOperation") then
		part.UsePartColor = true
	end
	if part:IsA("SpecialMesh") then
		part.TextureId = "rbxassetid://0"
	end
	wait(.3)
end

connection = bin.Touched:connect(onTouched) 

Do not ask people to write entire scripts or design entire systems.

do you want to change textures?

bin = script.Parent
local MeshPart = script

function onTouched(part)   
	part.BrickColor = BrickColor.new("Daisy orange")
	part.Material = Enum.Material.Glass
	part.Reflectance = 0.15
	if part:IsA("UnionOperation") then
		part.UsePartColor = true
	elseif part:IsA("SpecialMesh") then
		part.TextureId = "rbxassetid://0"
	wait(.3)
end

connection = bin.Touched:connect(onTouched) 

You could try part.TextureId = nil or Part.TextureId = "".

Also, use :Connect instead of :connect.

1 Like

basically trying to change the mesh texture Id but, the code doesn’t seem to do so.

did you try setting it to nil? part.TextureId = nil

still the same thing, does nothing.

that will mess up the mesh’s texture though.

it would have looked like this if it did worked

is there any errors in the output?

no errors at all, everything works fine. It changes the drink to gold even tho it doesn’t look like it did, it’s just hidden under that mesh texture.

here’s how you could do it.

if part:IsA("BasePart") and part:FindFirstChildOfClass("SpecialMesh") then
		part:FindFirstChildOfClass("SpecialMesh").TextureId = "rbxassetid://0"
	end

nice it works, apart from not needing the (“rbxassetid://0”) just the (" ") in it, thanks :slight_smile:

1 Like