Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

This script is not changing the colour of Wood parts?

Hi, I'm implementing a system where you can customize the colour of your gun. The RecolourValue is a BrickColorValue. It prints "1" and also prints "2", but does not print "3".

PrimaryMaterial = "Wood"

for i,v in pairs(script.Parent:GetChildren()) do
	
	print '1'	
	
	if v.ClassName == "Part" or v.ClassName == "WedgePart" then
		
		print '2'		
		
		if v.Material == (PrimaryMaterial) then		
			
			print '3'			
			
			v.BrickColor = BrickColor.new(script.Parent.Parent.Parent.shopandinventoryvalues.RecolourValue.Value)		
			
		end		
	
	end
	
end

Thanks for your help!

3 comments

2

Because you're comparing Material to a string rather than the material itself. Change (PrimaryMaterial) to Enum.Material.Wood

1

^ you beat me by 4 mins gg

0

oh dang okay, thanks ill try this when i get home

1 answer

✓ Accepted answer

Your using material as a string value, they are not strings. It is a special data type that are different from the commonly used ones such as numbers, strings, bools, stuff like that. To fix this use:

Enum. --whatever the material u want is

Read the wiki if you need more help: http://wiki.roblox.com/index.php?title=Enumeration

2 comments

1

Bear in mind you could also add .Name after Material since Enums have a Name property, which is the string version of the Enum.

0

Thanks spongo and lucas, it works great now.

This discussion is preserved as it was. New answers, comments, and votes are closed.