This is a support category for asking questions about how to get something done on the Roblox websites or how to do something on Roblox applications such as Roblox Studio.
What do you want to achieve? Keep it simple and clear!
-
I want to rotate parts randomly around a position
-
What is the issue? Include screenshots / videos if possible!
I can’t rotate a position for the rocks to form around so they are forming the same every time and it looks bad. -
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
I’ve tried looking around the forums but nobody seems to have the same problem as me.
function RockModule.crater1(character, Position, RockNum, Minsize, Maxsize)
local radius = math.random(Minsize,Maxsize)
RockModule.CheckDebrisFolder()
local raycastParams = RaycastParams.new()
local thingstoignore = {}
if thingstoignore then
for i, v in pairs(workspace.Characters:GetChildren()) do
table.insert(thingstoignore, v)
end
for i, v in pairs(DebrisFolder:GetChildren()) do
table.insert(thingstoignore, v)
end
for i, v in pairs(workspace:GetChildren()) do
if v:IsA("Part") and v.Name == "HitBox" then
table.insert(thingstoignore, v)
end
end
end
raycastParams.FilterType = Enum.RaycastFilterType.Exclude
raycastParams.FilterDescendantsInstances = {thingstoignore}
raycastParams.IgnoreWater = true
local StartingPoint = Position + Vector3.new(0, 1, 0)
local ray = workspace:Raycast(StartingPoint, Vector3.new(0,-5,0), raycastParams)
if ray then
print(ray.Instance)
for i = 1,RockNum do
coroutine.wrap(function()
local randomSize = RockModule.RandomVector3(radius / 2.5)
local angle = 2 * math.pi / RockNum * i
local clone = game.ReplicatedStorage.DebrisRelated.Part1:Clone()
clone.Name = "Rock"
clone.Parent = DebrisFolder
clone.Anchored = true
clone.Size = Vector3.new(0,0,0)
clone.Transparency = 0
clone.CollisionGroup = "Debris"
clone.CanCollide = true
clone.Position = ray.Position + Vector3.new(radius * math.cos(angle), -0.5, radius * math.sin(angle))
clone.CFrame = CFrame.lookAt(clone.Position, ray.Position)
clone.CFrame = clone.CFrame * CFrame.Angles(math.rad(math.random(10,25)), math.rad(math.random(-10,10)), math.rad(math.random(-10,10)))
TweenService:Create(clone, TweenInfo.new(0.2, Enum.EasingStyle.Linear), {Size = randomSize}):Play()
if thingstoignore then
for i, v in pairs(workspace.Characters:GetChildren()) do
table.insert(thingstoignore, v)
end
for i, v in pairs(DebrisFolder:GetChildren()) do
table.insert(thingstoignore, v)
end
for i, v in pairs(workspace:GetChildren()) do
if v:IsA("Part") and v.Name == "HitBox" then
table.insert(thingstoignore, v)
end
end
end
raycastParams.FilterDescendantsInstances = {thingstoignore}
local ray2 = workspace:Raycast(clone.CFrame.Position + Vector3.new(0,7,0), Vector3.new(0,(-radius * 1.5),0), raycastParams)
if ray2 then
print(ray2.Instance)
clone.Color = ray2.Instance.Color
clone.Material = ray2.Instance.Material
clone.Transparency = ray2.Instance.Transparency
else
clone:Destroy()
end
end)()
end
task.wait(10000)
RockModule.ClearDebris("Crater1")
end
end
What’s Happening
What I want