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

Help anyone? (string expected, got boolean)

when i walk onto a part material get the error (string expected, got boolean) and the mv.Value wont change thus breaking the rest of the script can i not change the stringvalue Value by touching a part material

script.Parent:WaitForChild("LeftFoot", "RightFoot").Touched:Connect(function(tuch)
	local mv = script.Material
	mv.Value = tuch.Material == Enum.Material --error occurs here

1 answer

✓ Accepted answer

You must do Enum.Material.MaterialNameHere . When you type Enum.Material.it will try and finish your sentence by giving you a short list of Material Enums. View more about Enums here.

Edit

script.Parent:WaitForChild("LeftFoot", "RightFoot").Touched:Connect(function(tuch) -- tuch is the thing it touches.
    local mv = script:WaitForChild("Material") 
    mv.Value = tuch.Material -- tuch's material.

9 comments

0

when i add Material.Air to the end i still get the same error

0

Air isn't a material.

0

It has to be a material that you can use on parts. If you want to use material for terrain it will have to include Region3, which is quite hard.

0

true its just a void space but even if i change the material the Value of the string value wont change

0

Oh I see. Let me edit my answer.

0

I was confused at first sorry lol.

0

its okay i didnt explain the problem well but when i changed code i just got another error (string expected, got EnumItem)

0

Maybe change tuch.Material to tuch.Material.Name ?

0

yes it cleared up the error and everything is working now ty you so much been at that for 2 hours

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