I am currently making a car spawn GUI using the :MoveTo() function, But it does not teleport it exactly to the player.
Video of the code working:
Code:
function spawncar(plr,car,col)
local carclone = game.ServerStorage.Vehicles:FindFirstChild(car):Clone()
carclone.Name = (plr.Name.."Spawned")
carclone.Parent = workspace
carclone:MoveTo (plr.Character.HumanoidRootPart.Position)
carclone.Body.Plate.Event:Fire()
carclone.Body.Plate.Event:Fire()
if carclone.Body:FindFirstChild("Paint") then
carclone.Body.Paint.Paint.BrickColor = col
end
plr.PlayerGui.Menu.Notif.PushNotif:FireAllClients("Car Spawned","You have spawned a "..car..".")
end
local Event = game.ReplicatedStorage.CarEvents.Spawn
Event.OnServerEvent:Connect(function(plr,car,col)
if workspace:FindFirstChild(plr.Name.."Spawned") then
plr.Character.Humanoid.Sit = false
wait(0.1)
workspace:FindFirstChild(plr.Name.."Spawned"):Destroy()
wait(.3)
plr.PlayerGui.Menu.Notif.PushNotif:FireAllClients("Car Despawned","Your vehicle has been despawned.")
wait(.3)
spawncar(plr,car,col)
else
spawncar(plr,car,col)
end
end)