Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local function getclosest(zone)
- local distance = math.huge
- local closest
- local minethings = game:GetService("Workspace").Storage.Clickables[zone]:GetChildren()
- for i=1,#minethings do
- local v = minethings[i]
- if v:IsA("Model") and v.PrimaryPart and game.Players.LocalPlayer:DistanceFromCharacter(v.PrimaryPart.Position)<distance then
- distance = game.Players.LocalPlayer:DistanceFromCharacter(v.PrimaryPart.Position)
- closest = v
- end
- end
- return closest
- end
- local petids = {}
- spawn(function()
- while wait()do
- local pets = game:GetService("Workspace").Storage.Pets.Garbage[game.Players.LocalPlayer.Name]:GetChildren()
- local zone
- for i=1,#pets do
- local v = pets[i]
- if v:FindFirstChild("PetClientModule") then
- local a = require(v.PetClientModule)
- if a.MiningZone ~= nil then
- zone = a.MiningZone
- end
- if not table.find(petids,v) then
- table.insert(petids,v)
- end
- end
- end
- if zone then
- for i=1,#petids do
- local v = petids[i]
- game:GetService("ReplicatedStorage").Events.PartUpdateEvent:FireServer({
- ["PartName"] = getclosest(zone).Name,
- ["PetId"] = v.Name,
- ["UpdateType"] = "StartMining",
- ["Zone"] = zone,
- })
- end
- end
- end
- end)
- game:GetService("Workspace").Storage.Pets.Garbage[game.Players.LocalPlayer.Name].ChildRemoved:Connect(function(a)
- local b = a
- for i=1,#petids do
- local v = petids[i]
- if tostring(v) == tostring(b) then
- table.remove(petids,i)
- end
- end
- end)
Add Comment
Please, Sign In to add comment