Hello, im making a game inspired by Super Bomb Survival, as of right now im making a explosion module so i can make the player go boom.
But im having a problem, since my explosion is a model i have to use model:MoveTo(), but when i do it, it just stays at the original position of the model, not the position i want, i dont know if model:PivotTo() will work since im passing a Vector3 value not a CFrame and i don´t want to pass a CFrame value becouse of varius reasons.
This is how my model is organized:
The meshes are just the ball model, but the PrimaryPart is the part that emmits the sound and the primary part of the model; I tried moving PrimaryPart since is the primary part of my model but it gives the same results.
This is the part of the code where im having problems:
function Explosion:Explode()
task.spawn(function()
local explosionClone = self.Model:Clone()
explosionClone:MoveTo(self.Position) --Wont work :(
explosionClone.Parent = workspace
local soundClone = sound:Clone()
soundClone.Parent = explosionClone:FindFirstChild("PrimaryPart")
soundClone:Play()
task.delay(2, function()
explosionClone:Destroy()
end)
end)
end
This is a script which calls the creation of a explosion:
This is the result, as you can see, the model is not in the position i want it to be.
:MoveTo() I’ve heard in some places that it’s deprecated and often doesn’t work and you should switch to :PivotTo(). As for :PivotTo() it only takes a CFrame and nothing else. To implement your fix to Explosion:Explode(), you use a CFrame constructor with a Vector3.
function Explosion:Explode()
task.spawn(function()
local explosionClone = self.Model:Clone()
explosionClone:PivotTo(CFrame.new(self.Position)) -- Try this fix :)
explosionClone.Parent = workspace
local soundClone = sound:Clone()
soundClone.Parent = explosionClone:FindFirstChild("PrimaryPart")
soundClone:Play()
task.delay(2, function()
explosionClone:Destroy()
end)
end)
end
The model should move to the desired place but without orientation because of Vector3.Position represents pure position data and no orientation if that’s your goal.
--At the top of the script (or anywhere before your function)
local Debris = game:GetService("Debris")
--Now in your function
Debris:AddItem(explosionClone, 2) --Deletes the explosionClone after 2 seconds