Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Settings
- local partSize = Vector3.new(.4, .4, .1) -- Size of each part
- local gridSize = 200 -- Number of parts along one side of the grid
- local gridCenter = Vector3.new(0, 0, 0) -- Center of the grid
- local noiseScale = 0.1 -- Scale of Perlin noise for turbulence smoothness
- local turbulenceScale = 1 -- Intensity of the turbulence
- local colorSpeed = 0.8 -- Speed of color changes
- local movementSpeed = 0.5 -- Speed of turbulence pattern movement
- local parentModelName = "FlowingTurbulenceGrid" -- Name of the Model to group the parts
- -- Create a parent model to hold the parts
- local model = Instance.new("Model")
- model.Name = parentModelName
- model.Parent = workspace
- -- Function to generate turbulence-like RGB colors
- local function turbulenceToColor(x, y, timeOffset)
- -- Create a turbulence effect by combining multiple noise values
- local offsetX = math.noise(x * noiseScale, y * noiseScale, timeOffset * movementSpeed) * turbulenceScale
- local offsetY = math.noise(x * noiseScale + 10, y * noiseScale, timeOffset * movementSpeed) * turbulenceScale
- -- Compute the Perlin noise for RGB using turbulence offsets
- local r = math.noise(x * noiseScale + offsetX, y * noiseScale + offsetY, timeOffset * colorSpeed)
- local g = math.noise(x * noiseScale + offsetY, y * noiseScale - offsetX, timeOffset * colorSpeed)
- local b = math.noise(x * noiseScale - offsetX, y * noiseScale - offsetY, timeOffset * colorSpeed)
- -- Map values from [-1, 1] to [0, 1]
- r = math.clamp((r + 1) / 2, 0, 1)
- g = math.clamp((g + 1) / 2, 0, 1)
- b = math.clamp((b + 1) / 2, 0, 1)
- return Color3.new(r, g, b)
- end
- -- Calculate half grid size for centering
- local halfGridSize = (gridSize - 1) * partSize / 2
- -- Store parts for animation
- local parts = {}
- -- Generate the grid of parts
- for x = 0, gridSize - 1 do
- for y = 0, gridSize - 1 do
- -- Calculate part position
- local posX = gridCenter.X + (x * partSize.X - halfGridSize.X)
- local posY = gridCenter.Y + (y * partSize.Y - halfGridSize.Y)
- local posZ = gridCenter.Z -- Flat 2D grid on the Z-axis
- local position = Vector3.new(posX, posY, posZ)
- -- Create and configure the part
- local part = Instance.new("Part")
- part.Size = partSize
- part.Position = position
- part.Anchored = true
- part.Parent = model
- table.insert(parts, {Part = part, GridX = x, GridY = y})
- end
- end
- -- Animate the colors for flowing turbulence effect
- game:GetService("RunService").Heartbeat:Connect(function(deltaTime)
- local time = wait() * movementSpeed -- Use `tick()` to create a time offset
- for _, data in pairs(parts) do
- local part = data.Part
- local x = data.GridX
- local y = data.GridY
- -- Assign dynamic color based on turbulence-like noise
- part.Color = turbulenceToColor(x, y, time)
- end
- end)
Advertisement
Add Comment
Please, Sign In to add comment