local fishes = workspace.Game.Fishes
local player = game:GetService("Players").LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local rootPart = character:WaitForChild("HumanoidRootPart")
local RebirthConfig = require(game:GetService("ReplicatedStorage").Shared.Dir.RebirthConfig)
local rebirthRemote = workspace:WaitForChild("Network"):WaitForChild("RebirthRequest-RemoteEvent")
local touchPart = workspace.Game.Plots:WaitForChild(player.Name).AquariumPlatform.TouchPart
local playerId = tostring(player.UserId)
local busy = false
local function getNeededFish()
local currentRebirth = player:GetAttribute("Rebirth") or 0
local nextTier = currentRebirth + 1
local req = RebirthConfig[nextTier]
if not req then return {} end
local needed = {}
for _, fish in ipairs(req.Requirements.Fish or {}) do
needed[fish.Name] = false
end
return needed
end
local function checkOwnedFish(needed)
for _, fish in ipairs(fishes:GetChildren()) do
local name = fish:GetAttribute("Name") or fish.Name
local owner = tostring(fish:GetAttribute("Owner") or "")
if needed[name] ~= nil and owner == playerId then
needed[name] = true
end
end
return needed
end
local function allCollected(needed)
for _, v in pairs(needed) do
if not v then return false end
end
return true
end
task.spawn(function()
while true do
task.wait(0.1)
if busy then continue end
local needed = getNeededFish()
local owned = checkOwnedFish(needed)
if allCollected(owned) then
rebirthRemote:FireServer()
task.wait(2)
continue
end
local foundFish = false
for _, fish in ipairs(fishes:GetChildren()) do
local name = fish:GetAttribute("Name") or fish.Name
local owner = fish:GetAttribute("Owner")
if owned[name] == false and not owner then
foundFish = true
busy = true
rootPart.CFrame = CFrame.new(fish:GetPivot().Position + Vector3.new(0, 5, 0))
task.wait(0.2)
local prompt = fish.RootPart:FindFirstChild("ProximityPrompt")
if prompt then
fireproximityprompt(prompt)
end
task.wait(0.2)
rootPart.CFrame = CFrame.new(touchPart.Position + Vector3.new(0, 3, 0))
task.wait(0.5)
busy = false
break
end
end
if not foundFish then
task.wait(1)
end
end
end)
Comments
No comments yet
Be the first to share your thoughts!