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

Material Determination Script [IS IT FUNCTIONAL?] (NOT SOLVED)

Basically, in this script I'm creating, it detects the part's name, and then inserts a texture onto the part, according to the name. I'm wondering if what I've written so far is correct.

while true do
	function determineMaterial()
		if Part.Name == "MetalWall001"
			then
		local metal001 = Instance.new.Texture
		metal001.Texture = "http://www.roblox.com/asset/?id=190629879"
		metal001.Face = "Left"
		metal001.Face = "Right"
		metal001.Face = "Back"
		metal001.Face = "Front"
		local metal001a = instance.new.Texture
		metal001a.Texture = "http://www.roblox.com/asset/?id=190629867"
		metal001a.Face = "Top"
		end
	end
end

2 answers

You have many, many problems here.

  • There is no wait() in the while loop; it will crash your game.

  • The function is never called, so it will never run.

  • Part will cause an error; there is no Part variable defined anywhere in the script.

  • The correct format for creating new instances is Instance.new("InstanceName", parent)

  • You never set the parent of the Texture created, so it will not exist in the actual game.

  • When setting Image or Texture properties, you must subtract 1 from the ID. You didn't.

  • Setting the Face of the object repeatedly is completely pointless. If you want it to appear on all faces, you must create multiple objects.

I would give you code, but it appears you still need to learn some of the basics of Lua. You can study on the wiki or with the video tutorials Roblox made.

3 comments

0

I'd appreciate some code, but alright. I'll try to fix this.

1

By the way, subtracting 1 from the ID doesn't always get you the ROBLOX Image asset. You occasionally have to subtract more, so you should always check on the website first..

0

Thanks for that.

THat script completely ruins the point of the script.

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