Hello, sometime i was trying to create a gpo-like rock debris system, it works perfectly, but when i move it with rotation it works strange. I want rocks to rotate with the part that moving. I made that with a tutorial but modified it some
_index.trail = function(Settings : {})
local self = {}
if Settings then
self.Part = Settings.Part
self.Size = Settings.Size or Vector3.new(math.random(3,5), math.random(3,5), math.random(3,5))
self.Distance = Settings.Distance or 1
self.Lifetime = Settings.Lifetime or 2.5
self.Height = Settings.Height or 1.25
self.CanCollide = Settings.CanCollide or false
self.Time = Settings.Time or .3
self.Connection = nil
end
local cd=false
self.Connection = game:GetService("RunService").Heartbeat:Connect(function()
if cd == false then
cd = true
local Result = workspace:Raycast(self.Part.Position + Vector3.new(0,1,0), Vector3.new(0,-10,0), parameters)
local function CreateRock(Distance)
local Part = Instance.new("Part", Temp)
Part.Anchored = true
Part.CanCollide = self.CanCollide
Part.Transparency = Result.Instance.Transparency
Part.Color = Result.Instance.Color
Part.Material = Result.Material
Part.Name = "GroundDebris"
Part.CanQuery = false
Part.Size = Vector3.new(self.Size.X, self.Size.Y, self.Size.Z)
Part.Position = Result.Position - Vector3.new(0,self.Height / self.Distance,0) - Vector3.new(0,0,3 * Distance)
local Multiplier = 1
if Distance < 0 then Multiplier = -1 end
Part.CFrame *= CFrame.Angles(math.rad(math.random(10,47) * Multiplier),0,0)
return Part
end
if Result then
local Part = CreateRock(-self.Distance)
local Part2 = CreateRock(self.Distance)
task.delay(self.Lifetime, function()
Part:Destroy()
Part2:Destroy()
end)
end
task.delay(self.Time / 2.75, function()
cd = false
end)
end
end)
return self.Connection
end
Thats a module script, so dont mind _index
variable.
Here how is it exactly works., there are also another video to make it more clear