I want to use a mesh in a script but you can't put an ID for meshparts in scripts, how would I put a mesh in a script like you would with with a part? For example if you wanted to insert a part you would just do Instance.new but how would I do something similar with a mesh?
I tried putting the meshes in serverstorage then cloning them but that didn't work properly, the script works fine if you are alone but if 2 players activate it then the meshes teleport to the player that activated it last, this is the script:
local ReplicatedStorage = game:GetService("ReplicatedStorage") local Table = {} ReplicatedStorage.RemoteEvent3.OnServerEvent:Connect(function(player) local ServerStorage = game.ServerStorage local function ShockWave() wait(0.6) game.ServerStorage.ShockWaveMesh:Clone().Parent = game.Workspace local ShockWave = game.Workspace.ShockWaveMesh ShockWave.Position = player.Character.RightHand.Position ShockWave.Orientation = player.Character.HumanoidRootPart.Orientation ShockWave.Size = Vector3.new(1,1,0.5) ShockWave.Transparency = 0.5 ShockWave.CanCollide = false game.ServerStorage.ShockWaveMesh2:Clone().Parent = game.Workspace local BodyVelocity = Instance.new("BodyVelocity") local ShockWave2 = game.Workspace.ShockWaveMesh2 BodyVelocity.Parent = ShockWave2 ShockWave2.Orientation = ShockWave.Orientation ShockWave2.Position = ShockWave.Position ShockWave2.Size = Vector3.new(5,5,5) ShockWave2.Transparency = 0.5 ShockWave2.CanCollide = false BodyVelocity.MaxForce = Vector3.new(math.huge,math.huge,math.huge) BodyVelocity.Velocity = ShockWave.CFrame.lookVector * 40 ShockWave2.Touched:Connect(function(hit) local humanoid = hit.Parent:FindFirstChild("Humanoid") if humanoid and hit.Parent.Name ~= player.Name then local found = false for i = 1,#Table do if Table[i] == hit.Parent.Name then found = true end end if found == false then table.insert(Table,game.Players:GetPlayerFromCharacter(hit.Parent).Name) humanoid:TakeDamage(30) found = true wait(3) for i = 1,#Table do if Table[i] == hit.Parent.Name then table.remove(Table,i) end end end end end) spawn(function() for i = 1,100 do wait() ShockWave.Size = ShockWave.Size + Vector3.new(1,1,0.01) ShockWave.Transparency = ShockWave.Transparency + 0.005 ShockWave2.Size = ShockWave2.Size + Vector3.new(1,1,1) ShockWave2.Transparency = ShockWave2.Transparency + 0.005 if ShockWave.Transparency == 1 or i == 100 or ShockWave2.Transparency == 1 then ShockWave:Destroy() ShockWave2:Destroy() end end end) spawn(function() for i = 1,100 do wait() ShockWave2.Orientation = ShockWave2.Orientation + Vector3.new(0,0,3) ShockWave2.Position = ShockWave2.Position + Vector3.new(0,0.1,0) end end) end ShockWave() end)
Prepare your meshes beforehand and clone them whenever you need them, as far as I know there's no way to load meshes at runtime other than maybe using the InsertService:
https://developer.roblox.com/en-us/api-reference/function/InsertService/LoadAsset