I am trying to create a thing so when the block hits a brick it's meshID changes.
local Changeable = game.workspace.Changeable local Mesh = game.workspace.Changeable.Mesh script.Parent.Touched:connect(function(obj) if obj:FindFirstChild("Changeable") ~= nil then Mesh.MeshId = "http://www.roblox.com/asset/?id=79429148" Changeable.Name = "RailIn" end end)
First off on line 2, your variable is
local Mesh = game.Workspace.Changeable.Mesh
when you already have a variable to the "Changable" part. Change that variable to:
local Mesh = Changeable:WaitForChild("Mesh")
By doing what is above tells the script not to run until they can verify that there is a mesh in Changeable.
Also, your "if" statement. You asking if there is a part inside the part you touched. To fix this, change it to,
if obj == Changeable then Mesh.MeshId = "http://www.roblox.com/asset/?id=79429148" Changeable.Name = "RailIn" end
Hope this helped