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

Why Won't This Script Work???

Asked by 9 years ago

Please make your question title relevant to your question content. It should be a one-sentence summary in question form.

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
I don't think you have to put all these meshid's in curly brackets, just one at start and one at the end. damagex443 325 — 9y

1 answer

Log in to vote
1
Answered by 9 years ago

Please provide explanation with your answers. Simply posting code does not spread knowledge of integral scripting processes which helps people understand the logic and reasoning behind your 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)
0
I tried it but it did not work Anthony9960 210 — 9y
Ad

Answer this question