I made the luckyblock model I also made a 2 parts called (SpawnLuckyblockPart) and (DestrotyluckyblockPart) so it spawns from the spawn and then goes to destroy luckyblock part
Assistant
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.
Great! I'll update the LuckyBlockSpawner script to use your custom model and the spawn/destroy parts you created:
lua
-- LuckyBlockSpawner
local workspace = game:GetService("Workspace")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
-- Find the spawn and destroy parts
local spawnPart = workspace:WaitForChild("SpawnLuckyblockPart")
local destroyPart = workspace:WaitForChild("DestrotyluckyblockPart")
-- Create folder for lucky blocks if it doesn't exist
local blockFolder = workspace:FindFirstChild("LuckyBlocks")
if not blockFolder then
blockFolder = Instance.new("Folder")
blockFolder.Name = "LuckyBlocks"
blockFolder.Parent = workspace
end
-- Function to create and manage a lucky block
local function createLuckyBlock()
-- Use your custom model
local luckyBlockModel = game.ReplicatedStorage:FindFirstChild("LuckyBlock"):Clone()
-- Position at spawn part
luckyBlockModel:PivotTo(spawnPart.CFrame)
-- Set up movement
local mainPart = luckyBlockModel.PrimaryPart or luckyBlockModel:FindFirstChildWhichIsA("BasePart")
if mainPart then
-- Add floating effect
local bodyPosition = Instance.new("BodyPosition")
bodyPosition.MaxForce = Vector3.new(math.huge, math.huge, math.huge)
bodyPosition.Position = mainPart.Position
bodyPosition.P = 10000
bodyPosition.D = 1000
bodyPosition.Parent = mainPart
-- Add spinning
local bodyAngularVelocity = Instance.new("BodyAngularVelocity")
bodyAngularVelocity.AngularVelocity = Vector3.new(0, 2, 0)
bodyAngularVelocity.MaxTorque = Vector3.new(0, math.huge, 0)
bodyAngularVelocity.Parent = mainPart
-- Move from spawn to center of map
local centerPosition = Vector3.new(0, spawnPart.Position.Y + 5, 0)
local currentPosition = spawnPart.Position
-- Set up movement animation
local startTime = tick()
local moveDuration = 5 -- seconds to move to center
local floatDuration = math.random(20, 30) -- seconds to float before being destroyed
local floatStartY = centerPosition.Y
luckyBlockModel.Parent = blockFolder
-- Movement update loop
local connection
connection = game:GetService("RunService").Heartbeat:Connect(function()
local elapsed = tick() - startTime
-- First phase: Move to center
if elapsed < moveDuration then
local alpha = elapsed / moveDuration
local newPosition = currentPosition:Lerp(centerPosition, alpha)
bodyPosition.Position = newPosition
-- Second phase: Float at center
elseif elapsed < moveDuration + floatDuration then
-- Add floating animation
bodyPosition.Position = Vector3.new(
centerPosition.X + math.sin(elapsed) * 5,
floatStartY + math.sin(elapsed * 2) * 2,
centerPosition.Z + math.cos(elapsed) * 5
)
-- Final phase: Move to destroy part
elseif elapsed < moveDuration + floatDuration + 3 then
local alpha = (elapsed - (moveDuration + floatDuration)) / 3
local newPosition = centerPosition:Lerp(destroyPart.Position, alpha)
bodyPosition.Position = newPosition
-- Destroy the block
else
if luckyBlockModel and luckyBlockModel.Parent then
luckyBlockModel:Destroy()
end
connection:Disconnect()
end
-- Disconnect if model is destroyed
if not luckyBlockModel or not luckyBlockModel.Parent then
connection:Disconnect()
end
end)
end
end
-- Spawn blocks continuously
while true do
task.wait(math.random(3, 8))
if #blockFolder:GetChildren() < 10 then
createLuckyBlock()
end
end
Also, let's update the client controller to work with your custom model:
lua
-- Add this to the client controller, replacing the existing lucky block collection code
RunService.Heartbeat:Connect(function()
local blockFolder = workspace:FindFirstChild("LuckyBlocks")
if blockFolder and character and humanoidRootPart then
for _, luckyBlock in ipairs(blockFolder:GetChildren()) do
-- Get the primary part or any part in the model
local mainPart = luckyBlock.PrimaryPart or luckyBlock:FindFirstChildWhichIsA("BasePart")
if mainPart then
local distance = (mainPart.Position - humanoidRootPart.Position).Magnitude
if distance < 8 then
-- Animate collection effect
for _, part in pairs(luckyBlock:GetDescendants()) do
if part:IsA("BasePart") then
part.CanCollide = false
local bodyPos = Instance.new("BodyPosition")
bodyPos.Position = humanoidRootPart.Position
bodyPos.MaxForce = Vector3.new(math.huge, math.huge, math.huge)
bodyPos.P = 20000
bodyPos.Parent = part
-- Fade out
spawn(function()
for i = 1, 10 do
part.Transparency = i/10
wait(0.03)
end
end)
end
end
-- Wait briefly for animation
spawn(function()
wait(0.3)
luckyBlock:Destroy()
-- The server will handle adding to inventory
end)
end
end
end
end
end)
This updated code:
Uses your custom LuckyBlock model from ReplicatedStorage
Spawns blocks at the SpawnLuckyblockPart
Makes them move to the center, float around, then go to the DestroyLuckyblockPart
Adds animations for block collection
Preserves all the game mechanics from the original code
Would you like me to explain any part of this code in more detail or make any other adjustments?