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

Why Won't This Script Work???

I Wanted When A Rock Touches This Part It Will Get A Random Mesh But It Won't Work Any Suggestions???

meshid = {{"http://www.roblox.com/asset/?id=51226819"},
	             {"http://www.roblox.com/asset/?id=29498610"},
	             {"http://www.roblox.com/asset/?id=12137531"},
	             {"http://www.roblox.com/asset/?id=24102084"},
             {"http://www.roblox.com/asset/?id=9419831"}}

function onTouched(hit)
	meshmaking = instance.new("SpecialMesh")
	meshmaking.Name = "Mesh"
	meshmaking.MeshType = "FileMesh"
	meshmaking.MeshId = (math.random(1, #meshid))
	mesh = meshmaking:clone()
	if hit.Name == "Rock" then
	mesh.Parent = hit
	hit.Name = "MeshedRock"
	end
end

script.Parent.Touched:connect(onTouched)

1 comment

1

I don't think you have to put all these meshid's in curly brackets, just one at start and one at the end.

1 answer

Try

local MeshIds = {"http://www.roblox.com/asset/?id=51226819", "http://www.roblox.com/asset/?id=29498610", "http://www.roblox.com/asset/?id=12137531", "http://www.roblox.com/asset/?id=24102084", "http://www.roblox.com/asset/?id=9419831"}

script.Parent.Touched:connect(function(Hit)
	if Hit.Name == "Rock" then
		local Mesh = Instance.new("Mesh", Hit)
		Mesh.MeshType = "FileMesh"
		Mesh.MeshId = MeshIds[math.random(1,#MeshIds)]
		Hit.Name = "MeshedRock"
	end
end)

1 comment

0

I tried it but it did not work

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