Advertisement
IHATEMICROWAVEOVEN

eea

May 12th, 2023 (edited)
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.42 KB | None | 0 0
  1. -- INITIALIZATION
  2. local spawnTimer = 10 -- in seconds
  3. local maxAmt = 99
  4. -- local chatColor = Color3.new(1, 1, 0.1)
  5. local chatColor = Color3.new(1, 1, 1)
  6. local specialText = {
  7. [“Farticuno”] = {“PLAYER has obtained Farticuno… WHAT???”, “A cold one… with the boys!?”}
  8. }
  9. -- Data structure of specialText (a dictionary):
  10. -- keys are pokemon names, values are an array containing
  11. -- 1: server message (PLAYER=player’s name) and 2: client message
  12. -- When a
  13.  
  14. local SSServ = game:GetService("ServerScriptService")
  15. local Stats = require(SSServ:WaitForChild(“Stats”))
  16. local Toucher = require(SSServ:WaitForChild("Libraries"):WaitForChild("OnTouched"))
  17. local chatEvent = game.ReplicatedStorage:FindFirstChild(“ChatEvent”)
  18. local foo = task
  19. local amt = 0
  20.  
  21.  
  22.  
  23. -- FUNCTIONS
  24. local function sendNotification(plr, text, t)
  25. if chatEvent then
  26. chatEvent:FireClient(plr, “NaroZinC: ”, text, chatColor, chatColor, “”, t, “”)
  27. end
  28. end
  29.  
  30. local function generateMon() -- mon chances
  31. -- lazy to type it
  32. -- should return a string of the mon name
  33. end
  34.  
  35. local function findSpawn(mon)
  36. local spawnDict = script[mon]:GetChildren()
  37. while true do
  38. local possible = spawnDict[math.random(1, #spawnDict)]
  39. if possible.Name ~= “T” then return possible end -- probably breaks the loop :thumbs_up:
  40. end
  41. end
  42.  
  43. local function rewardMon(plr, mon)
  44. Stats.SetStat(plr, mon, 1)
  45. local selfText = “You got “..mon..”!”
  46. local servText = “GOTCHA! “..plr..” found the roaming “..mon..”!”
  47. if specialText[mon] then
  48. selfText = specialText[mon][2]
  49. servText = specialText[mon][1]
  50. local pIndex = 1
  51. while pIndex<=string.len(servText)-5 and string.sub(servText, pIndex, pIndex+5) ~= “PLAYER” do pIndex += 1 end
  52. if pIndex <= string.len(servText)-5 then
  53. servText = string.sub(servText, 1, pIndex-1)..plr..string.sub(servText, pIndex+1)
  54. end
  55. end
  56. sendNotification(p, selfText, true)
  57. for i, p in pairs(game.Players:GetChildren()) do sendNotification(p, servText, false) end
  58. end
  59.  
  60.  
  61.  
  62. -- MAIN METHOD
  63. local function doStuff()
  64. while true do
  65. foo.wait(spawnTimer)
  66.  
  67. if amt < maxAmt then
  68. amt += 1
  69. local monName = generateMon()
  70. local myBlock = findSpawn(myMon)
  71. local myMon = script.RModels:FindFirstChild(monName):Clone()
  72. myBlock.Name = "T" -- shows this spawn is taken
  73. myMon:SetPrimaryPartCFrame(myBlock.CFrame)
  74. myMon.Parent = workspace
  75. for i, p in pairs(game.Players:GetChildren()) do SendNotificaiton(p, “A wild “..monName..” appeared! DUNUNUNUnunununu bam bam bam bababam bum bam bam bam bababam”, false) end
  76.  
  77. local debounce = false
  78. Toucher.Touched(myMon.PrimaryPart, function(hit)
  79. if not debounce and thend”) then
  80. local plr = game.Players:GetPlayerFromCharacter(hit.Parent)
  81. debounce = true
  82. if Stats.GetStat(plr, monName) == 0 then
  83. rewardMon(plr, monName)
  84. myMon:Destroy()
  85. debounce = false
  86. myBlock.Name = “E” -- shows this spawn is empty
  87. end
  88. end)
  89. end
  90. end
  91. end
  92.  
  93. return doStuff
  94.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement