Basically, I have a script that chooses a random basepart or model parented to another object, and sets its CFrame to a certain position, and gives it one of four random orientations. However, sometimes the Y value gets set to an absurdly low value, and I dont know why.
The script:
local Hills = game.Workspace.Hills
local Tile = Hills.BasicTiles:GetChildren()[math.random(1, #Hills.BasicTiles:GetChildren())]:Clone()
local randomX = math.random(-1, 1)
local randomZ = math.random(-1, 1)
if randomX ~= 0 and math.random(1, 2) == 2 then
randomZ = 0
else
randomX = 0
end
if Tile:IsA("Model") then
Tile:PivotTo(CFrame.new(3950, 12.5, 3950))
Tile:PivotTo(CFrame.lookAt(Tile.PrimaryPart.Position, Tile.PrimaryPart.Position +Vector3.new(randomX, 0, randomZ)))
Tile.Parent = game.Workspace
else
Tile.CFrame = CFrame.new(3950, 12.5, 3950)
Tile.CFrame = CFrame.lookAt(Tile.Position, Tile.Position + Vector3.new(randomX, 0, randomZ))
Tile.Parent = game.Workspace
end