So i have a script that creates ore but i don't know why it dosen't spawn by the baseplate it has like it own position at 0,0,0 i want so the ores spawn on 0,100000,0
heres the script:
local oreDude = game.Workspace.Ores:GetChildren()
local oresize = Vector3.new(60/10,60/10,60/10)
local storeTable = {}
function CreateOre(pos)
local CanDo = true
if CanDo == true then
local MaxChance = {}
for i,v in pairs(game.ReplicatedStorage.Ores:GetChildren()) do
if v.Value == true and (v.Min.Value-1)*oresize.Y <= math.abs(pos.Y) and (v.Max.Value-1)*oresize.Y >= math.abs(pos.Y) then
for i = 1,v.Chance.Value do
table.insert(MaxChance,1,v.Name)
end
end
end
local random = game.ReplicatedStorage.Ores[MaxChance[math.random(1,#MaxChance)]]
local ID = random.Texture.Value
local ore = Instance.new("Part", game.Workspace.Ores)
local Color = Instance.new("Color3Value",ore)
Color.Name = "BackgroundColor3"
Color.Value = random.Color.Value
local Name = Instance.new("StringValue", ore)
Name.Name = "OreName"
Name.Value = random.Name
ore.TopSurface = Enum.SurfaceType.SmoothNoOutlines
ore.BottomSurface = Enum.SurfaceType.SmoothNoOutlines
ore.RightSurface = Enum.SurfaceType.SmoothNoOutlines
ore.LeftSurface = Enum.SurfaceType.SmoothNoOutlines
ore.FrontSurface = Enum.SurfaceType.SmoothNoOutlines
ore.BackSurface = Enum.SurfaceType.SmoothNoOutlines
ore.Size = oresize
ore.Material = Enum.Material.Slate
ore.BrickColor = random.StoneColor.Value
ore.Anchored = true
ore.Locked = false
ore.CFrame = CFrame.new(pos)
ore.Name = "Ore"
for i,v in pairs(random.Children:GetChildren()) do
v:Clone().Parent = ore
end
if ID ~= 0 then
for i,v in pairs({"Front", "Bottom", "Top", "Back", "Right", "Left"}) do
local decal = Instance.new("Decal", ore)
decal.Texture = ("http://www.roblox.com/asset/?id="..ID)
decal.Face = v
end
end
local value = Instance.new("BoolValue",ore)
value.Name = "LockedValue"
value.Value = false
local value2 = Instance.new("IntValue",ore)
value2.Name = "Hardness"
value2.Value = random.Hardness.Value
if pos.Y >= 0 then
value.Value = true
end
storeTable[tostring(pos)] = 0
end
end
game.ReplicatedStorage.ServerAndClient.MineOre.OnServerEvent:connect(function(plr,ore)
local Int = Instance.new("IntValue",game.ServerStorage.MineInWay)
Int.Name = tostring(ore.Position)
for x = 1,3 do
for z = 1,3 do
for y = 1,3 do
local pos = Vector3.new(ore.Position.X+(x-2)*ore.Size.X,ore.Position.Y+(y-2)*ore.Size.X,ore.Position.Z+(z-2)*ore.Size.X)
if pos.Y <= 0 and storeTable[tostring(pos)] == nil then
spawn(function() CreateOre(pos) end)
end
end
end
end
game.ReplicatedStorage.ServerOnlyEvents.AddToInv:Fire(plr,"Inventory",ore.OreName.Value)
ore:Destroy()
end)
function RestartMine()
game.Workspace.Ores:ClearAllChildren()
for X = 1,math.floor(game.Workspace.StopMine.Size.X/oresize.X) do
for Z = 1,math.floor(game.Workspace.StopMine.Size.X/oresize.X) do
local start = game.Workspace.StopMine.Position-Vector3.new(game.Workspace.StopMine.Size.X/2,game.Workspace.StopMine.Position.Y,game.Workspace.StopMine.Size.Z/2)
CreateOre(start+Vector3.new((X-0.5)*oresize.X,0,(Z)*oresize.Z))
if Z/20 == math.ceil(Z/10)/2 then
wait()
end
end
end
for i,v in pairs(game.Workspace.Ores:GetChildren()) do
if v:FindFirstChild("LockedValue") then
v.LockedValue.Value = false
end
end
game.Workspace.StopMine.Transparency = 1
game.Workspace.StopMine.CanCollide = false
game.Workspace.StopMine.CFrame = CFrame.new(game.Workspace.StopMine.Position +Vector3.new(0,100,0))
end
while true do
if #game.Workspace.Ores:GetChildren() > 100000 or #game.Workspace.Ores:GetChildren() == 0 then
RestartMine()
end
wait(10)
end
