Advertisement
HowToRoblox

EggHuntHandler

Apr 28th, 2020
2,017
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.70 KB | None | 0 0
  1. local eggs = workspace.Eggs:GetChildren()
  2.  
  3. local eggsFound = {}
  4.  
  5.  
  6. local plr = game.Players.LocalPlayer
  7.  
  8. local char = plr.Character or plr.CharacterAdded:Wait()
  9.  
  10.  
  11. local humanoid = char:WaitForChild("Humanoid")
  12.  
  13.  
  14. script.Parent.Text = "Eggs: 0/" .. #eggs
  15.  
  16.  
  17. humanoid.Touched:Connect(function(touch)
  18.    
  19.     for i, egg in pairs(eggsFound) do
  20.        
  21.         if egg == touch then return end
  22.     end
  23.    
  24.     if touch.Name == "Egg" then
  25.            
  26.         touch.Transparency = 1
  27.         touch.CanCollide = false       
  28.                
  29.         table.insert(eggsFound, touch)
  30.        
  31.         script.Parent.Text = "Eggs: " .. #eggsFound .. "/" .. #eggs
  32.        
  33.            
  34.         if #eggsFound == #eggs then
  35.            
  36.             game.ReplicatedStorage.OnAllEggsFound:FireServer() 
  37.         end
  38.     end
  39. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement