Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
2

This script is not changing the colour of Wood parts?

Asked by
pwnd64 106
8 years ago

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!

2
Because you're comparing Material to a string rather than the material itself. Change (PrimaryMaterial) to Enum.Material.Wood M39a9am3R 3210 — 8y
1
^ you beat me by 4 mins gg lucas4114 607 — 8y
0
oh dang okay, thanks ill try this when i get home pwnd64 106 — 8y

1 answer

Log in to vote
2
Answered by
lucas4114 607 Moderation Voter
8 years ago

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

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. Spongocardo 1991 — 8y
0
Thanks spongo and lucas, it works great now. pwnd64 106 — 8y
Ad

Answer this question