local replicatedstorage = game.ReplicatedStorage
local planetary = script.Parent:FindFirstChild("Planetary")

function Lerp(a, b, t)
    local qa = {
        QuaternionFromCFrame(a)
    }
    local qb = {
        QuaternionFromCFrame(b)
    }
    local ax, ay, az = a.x, a.y, a.z
    local bx, by, bz = b.x, b.y, b.z
    local _t = 1 - t
    return QuaternionToCFrame(_t * ax + t * bx, _t * ay + t * by, _t * az + t * bz, QuaternionSlerp(qa, qb, t))
end
local Lerp = CFrame.new().lerp
function QuaternionFromCFrame(cf)
    local mx, my, mz, m00, m01, m02, m10, m11, m12, m20, m21, m22 = cf:components()
    local trace = m00 + m11 + m22
    if trace > 0 then
        local s = math.sqrt(1 + trace)
        local recip = 0.5 / s
        return (m21 - m12) * recip, (m02 - m20) * recip, (m10 - m01) * recip, s * 0.5
    else
        local i = 0
        if m00 < m11 then
            i = 1
        end
        if i == 0 and m00 or m11 < m22 then
            i = 2
        end
        if i == 0 then
            local s = math.sqrt(m00 - m11 - m22 + 1)
            local recip = 0.5 / s
            return 0.5 * s, (m10 + m01) * recip, (m20 + m02) * recip, (m21 - m12) * recip
        elseif i == 1 then
            local s = math.sqrt(m11 - m22 - m00 + 1)
            local recip = 0.5 / s
            return (m01 + m10) * recip, 0.5 * s, (m21 + m12) * recip, (m02 - m20) * recip
        elseif i == 2 then
            local s = math.sqrt(m22 - m00 - m11 + 1)
            local recip = 0.5 / s
            return (m02 + m20) * recip, (m12 + m21) * recip, 0.5 * s, (m10 - m01) * recip
        end
    end
end
function QuaternionToCFrame(px, py, pz, x, y, z, w)
    local xs, ys, zs = x + x, y + y, z + z
    local wx, wy, wz = w * xs, w * ys, w * zs
    local xx = x * xs
    local xy = x * ys
    local xz = x * zs
    local yy = y * ys
    local yz = y * zs
    local zz = z * zs
    return CFrame.new(px, py, pz, 1 - (yy + zz), xy - wz, xz + wy, xy + wz, 1 - (xx + zz), yz - wx, xz - wy, yz + wx, 1 - (xx + yy))
end
function QuaternionSlerp(a, b, t)
    local cosTheta = a[1] * b[1] + a[2] * b[2] + a[3] * b[3] + a[4] * b[4]
    local startInterp, finishInterp
    if cosTheta >= 1.0E-4 then
        if 1 - cosTheta > 1.0E-4 then
            local theta = math.acos(cosTheta)
            local invSinTheta = 1 / math.sin(theta)
            startInterp = math.sin((1 - t) * theta) * invSinTheta
            finishInterp = math.sin(t * theta) * invSinTheta
        else
            startInterp = 1 - t
            finishInterp = t
            if 1 + cosTheta > 1.0E-4 then
                local theta = math.acos(-cosTheta)
                local invSinTheta = 1 / math.sin(theta)
                startInterp = math.sin((t - 1) * theta) * invSinTheta
                finishInterp = math.sin(t * theta) * invSinTheta
            else
                startInterp = t - 1
                finishInterp = t
                return a[1] * startInterp + b[1] * finishInterp, a[2] * startInterp + b[2] * finishInterp, a[3] * startInterp + b[3] * finishInterp, a[4] * startInterp + b[4] * finishInterp
            end
        end
    end
end

planetary.OnServerEvent:Connect(function(player, pos)
	local Character = player.Character

	local function gather(part, x)
		local Dirt = Instance.new("Part")
		Dirt.CFrame = Character.HumanoidRootPart.CFrame *CFrame.new(math.random(-20,20), math.random(-30,-5), math.random(-20,20))
		Dirt.Size = Vector3.new(x, x, x)
		Dirt.BrickColor = BrickColor.new("Brown")
		Dirt.Parent = part
		Dirt.Shape = Enum.PartType.Ball
		Dirt.Anchored = true
		Dirt.CanCollide = false
		Dirt.Material = Enum.Material.Grass
		for i = 0, 150 do
			Dirt.CFrame = Lerp(Dirt.CFrame, Character.HumanoidRootPart.CFrame * CFrame.new(0, 200, 0), .01)
			wait()
		end
		Dirt:Destroy()
	end
	local collect = true
	local ODirt = Instance.new("Part")
		ODirt.Size = Vector3.new(1, 1, 1)
		ODirt.BrickColor = BrickColor.new("Brown")
		ODirt.Parent = game.Workspace
		ODirt.Shape = Enum.PartType.Ball
		ODirt.Anchored = true
		ODirt.CanCollide = false
		ODirt.Material = Enum.Material.Grass
		ODirt.Name = "ODirt"

		wait()
		spawn(function()
			while collect do
				ODirt.CFrame = Lerp(ODirt.CFrame, Character.HumanoidRootPart.CFrame * CFrame.new(0, 200, 0), .01)
				wait()
			end
		end)
		spawn(function()
			while collect do
				spawn(function()
					gather(ODirt,math.random(4,10))
				end)
				wait(.2)
			end
		end)
		wait()
		spawn(function()
			for i = 0, 500 do
				ODirt.Size = ODirt.Size + Vector3.new(.25,.25,.25)
				wait()
			end
			collect = false
			wait(4)
			for i = 0, 500 do
				ODirt.CFrame = Lerp(ODirt.CFrame, pos, .01)
				wait()
			end
ODirt.Touched:Connect(function(hit)
	if hit.Parent:FindFirstChild("Humanoid") then 
		local EnemyHum = hit.Parent:FindFirstChild("Humanoid")
		EnemyHum:TakeDamage(45)
		
	end
end)
		ODirt:Destroy()
		end)
end)

2 comments

0

i wish i could help :( im so square brained i don't understand this../

0

if its a kill block then lord have mercy and here's the script if it is a kill block. script.Parent.Touched:Connect(function(Player) script.Parent.Humanoid.Health = 0 (i hope this helps lol idek if that even works tbh im a beginner)