Hey guys! I’m trying to achieve some sort of rock effect, however as shown in the gif, when it’s used on a baseplate it seems to work properly, however when used on a smaller part it’s like compacted in one place, I appreciate if anyone could help please, thanks.
https://gyazo.com/972897dbdb7214c3149788e2a514ac78
local yOffset = -0.2 --How far you want your parts to go down below the HMRP
local OtherPart = Instance.new("Part")
OtherPart.CFrame = HumanoidRootPart.CFrame
OtherPart.Anchored = true
OtherPart.CanCollide = false
OtherPart.Transparency = 0
OtherPart.Parent = workspace.Effects
OtherPart.Name = "Parttest"
game.Debris:AddItem(OtherPart, 5)
coroutine.resume(coroutine.create(function()
local function Part() -- Function to instantiate your part for each limb
local PartObject = Instance.new("Part")
PartObject.Parent = workspace.Effects
PartObject.FrontSurface = Enum.SurfaceType.Smooth
PartObject.TopSurface = Enum.SurfaceType.Smooth
PartObject.BottomSurface = Enum.SurfaceType.Smooth
PartObject.Name = "Parttest"
game.Debris:AddItem(PartObject, 5)
local RayOrigin = HumanoidRootPart.Position
local RayDirection = Vector3.new(0,-100,0)
local RaycastResult
local RaycastParam = RaycastParams.new()
RaycastParam.FilterDescendantsInstances = {HumanoidRootPart.Parent, workspace.Effects, HumanoidRootPart, OtherPart}
RaycastParam.FilterType = Enum.RaycastFilterType.Blacklist
RaycastResult = workspace:Raycast(RayOrigin, RayDirection, RaycastParam)
if RaycastResult then
print(RaycastResult.Instance)
print(RaycastResult)
local OffsetPart = Instance.new("Part")
OffsetPart.Name = "Testing"
game.Debris:AddItem(OffsetPart, 1)
OffsetPart.Position = RaycastResult.Position
OffsetPart.Anchored = true
OffsetPart.Size = Vector3.new(0.5,0.5,0.5)
OffsetPart.Parent = workspace.Effects
OffsetPart.Transparency = 0
OffsetPart.CanCollide = true
yOffset = OffsetPart.CFrame.Y
if yOffset > 2 then
yOffset = -yOffset/1.25
end
if yOffset < 1 then
yOffset = -2
end
PartObject.Position = RaycastResult.Position
PartObject.Material = RaycastResult.Material
end
PartObject.Anchored = true
PartObject.CanCollide = false
return PartObject
end
local total = 12 -->> Such as there are 8 limbs in this post
local radius = 10
for i=1,total do
local angle = (math.pi*2/total) * i -- There are 360 degrees in a circle or pi*2 radians
local x = radius * math.cos(angle)
local y = radius * math.sin(angle)
local part = Part()
Debris:AddItem(part, 5)
local RayOrigin = part.Position
local RayDirection = Vector3.new(0,-100,0)
local RaycastResult
local RaycastParam = RaycastParams.new()
RaycastParam.FilterDescendantsInstances = {model.Parent, workspace.Effects, model}
RaycastParam.FilterType = Enum.RaycastFilterType.Blacklist
RaycastResult = workspace:Raycast(RayOrigin, RayDirection, RaycastParam)
part.CFrame = model.CFrame * CFrame.new(x, yOffset, y)
if RaycastResult then
part.Position = RaycastResult.Position
end
part.Size = Vector3.new(3.824, 3.786, 3.44)
part.CFrame = CFrame.new(part.Position, model.Position) * CFrame.Angles(math.rad(math.random(-180,360)),math.rad(math.random(-180,360)),math.rad(math.random(-180,360)))
coroutine.resume(coroutine.create(function()
wait(3.5)
local Duration = TweenInfo.new(2.5, Enum.EasingStyle.Quad)
local DurationTwo = TweenInfo.new(0.35, Enum.EasingStyle.Quad)
game:GetService"TweenService":Create(part, Duration, {CFrame = OtherPart.CFrame * CFrame.new(0,-15,0)}):Play()
if part.Material == Enum.Material.Sand then
game:GetService"TweenService":Create(part, DurationTwo, {Size = Vector3.new(0.1, 0.1, 0.1)}):Play()
else
game:GetService"TweenService":Create(part, Duration, {Size = Vector3.new(0.3, 0.3, 0.3)}):Play()
end
end))
end
end))