I have this car spawner with the car in game.ServerStorage. The only problem is, that the MoveTo function does not move the car to the position to spawn it.
ction GenerateCar() --pcall(function() LastCar:Destroy() end) script.Parent.Gen.BillboardGui.Frame.Visible=true script.Parent.Gen.BillboardGui.Frame.TextLabel.Text="Covering Area." local clone=game.ServerStorage.Car:clone() clone:MoveTo(script.Parent.Cover.Position) wait()
Once the car starts to appear, it starts spawning in where it was cut and pasted to game.ServerStorage.
Any ways to c-frame models?
First off, I would recommend making sure you're parenting the car (which you do not appear to be doing ;P). Second off, here's a script that should CFrame models nicely:
function scan(v, t) -- This is called a recursive function for i, v in pairs(v:GetChildren()) do if (v:IsA("BasePart")) then table.insert(t, v) end scan(v, t) end end function cframeModel(model, basePart, cframe) -- basePart will have the exact same CFrame as "cframe". Other parts will be moved around it. local parts = {} scan(model, parts) -- This will update the parts table... tables are awesome! for i, part in pairs(parts) do print("Doing for part", part:GetFullName()) if (part ~= basePart) then local dist = basePart.CFrame:inverse() * part.CFrame part.CFrame = cframe * dist end end basePart.CFrame = cframe end cframeModel(game.Workspace.Model, game.Workspace.Model.BasePart, CFrame.new(0, 10, 0) * CFrame.Angles(0, math.rad(90), 0)) -- An example of how to use this
Note that basePart
will have the exact same CFrame as cframe
. Other parts will be moved around it accordingly.
model:TranslateBy(Vector3.new(0,1,0))
That will move the Model the distance specified by the Vector3. It works just like CFrame too. (in the way that it goes inside of things.)
function GenerateCar() --call (function() LastCar:Destroy() end) script.Parent.Gen.BillboardGui.Frame.Visible=true script.Parent.Gen.BillboardGui.Frame.TextLabel.Text="Covering Area.." clone=game.ServerStorage.Car:clone() clone:MoveTo(Vector3.new(script.Parent.Cover.Position)) wait()