FaZeJevs

Untitled

Nov 18th, 2015
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.60 KB | None | 0 0
  1. local Create = Instance.new('StringValue',script)
  2. Create.Value='Kid'
  3. local myname = Create.Value
  4.  
  5. local Rep=Instance.new('Model', script)
  6.  
  7. lastwordto = {}
  8.  
  9. function givehint(player, text)
  10. if player:findFirstChild("Message") ~= nil then player.Message:Remove() end
  11. local m = Instance.new("Hint")
  12. m.Text = text
  13. m.Parent = player
  14. end
  15.  
  16. function replace(str,a,b)
  17. while true do
  18. local i = string.find(str,a)
  19. if i == nil then return str end
  20. local j = i + #a
  21. i = i - 1
  22. str = string.sub(str,1, i).. b.. string.sub(str,j)
  23. end
  24. end
  25.  
  26. function removeextra(txt)
  27. txt = string.lower(txt)
  28. local bd = 0
  29. while true do
  30. local redo = false
  31. bd = string.find(txt, "'")
  32. if bd ~= nil then
  33. txt = string.sub(txt, 1, bd-1).. string.sub(txt, bd+1)
  34. redo = true
  35. end
  36. bd = string.find(txt, ",")
  37. if bd ~= nil then
  38. txt = string.sub(txt, 1, bd-1).. string.sub(txt, bd+1)
  39. redo = true
  40. end
  41. bd = string.find(txt, "\"")
  42. if bd ~= nil then
  43. txt = string.sub(txt, 1, bd-1).. string.sub(txt, bd+1)
  44. redo = true
  45. end
  46. bd = string.find(txt, "!")
  47. if bd ~= nil then
  48. txt = string.sub(txt, 1, bd-1).. string.sub(txt, bd+1)
  49. redo = true
  50. end
  51. bd = string.find(txt, "?")
  52. if bd ~= nil then
  53. txt = string.sub(txt, 1, bd-1).. string.sub(txt, bd+1)
  54. redo = true
  55. end
  56. bd = string.find(txt, "-")
  57. if bd ~= nil then
  58. txt = string.sub(txt, 1, bd-1).. string.sub(txt, bd+1)
  59. redo = true
  60. end
  61. if redo == false then break end
  62. end
  63. return txt
  64. end
  65.  
  66. function getresponse(txt, player)
  67. local basic = removeextra(txt)
  68. local poss = {}
  69. local rp = Rep:GetChildren()
  70. for i = 1, #rp do
  71. if basic == removeextra(rp[i].Name) then
  72. table.insert(poss, rp[i].Value)
  73. end
  74. end
  75. local rs = nil
  76. if #poss == 0 then
  77. if #rp == 0 then return nil end
  78. rs = rp[math.random(1,#rp)].Value
  79. else
  80. rs = poss[math.random(1, #poss)]
  81. end
  82. rs = replace(rs,"lukezammit", myname)
  83. rs = replace(rs,"lukezammit", player.Name)
  84. return rs
  85. end
  86.  
  87. function newresponse(a,b,c)
  88. if a == nil then a = "<NIL>" end
  89. local st = Rep:GetChildren()
  90. for i = 1, #st do
  91. if st[i].Name == a and st[i].Value == b then return end
  92. end
  93. local d = Instance.new("StringValue")
  94. d.Name = a
  95. d.Value= b
  96. local e = Instance.new("StringValue")
  97. e.Name = "Teacher"
  98. e.Value = c
  99. e.Parent = d
  100. d.Parent = Rep
  101. end
  102.  
  103. function chat(text, player)
  104. if string.lower(string.sub(text,1,#myname+1)) == string.lower(myname).. "/" then
  105. local msg = string.sub(text,#myname+2)
  106. msg = replace(msg, player.Name, "lukezammit")
  107. msg = replace(msg, myname, "lukezammit")
  108. local isaid = lastwordto[player.Name]
  109. local resp = getresponse(msg, player)
  110. newresponse(isaid, msg, player.Name)
  111. if resp ~= nil then
  112. lastwordto[player.Name]=resp
  113. else
  114. resp = "Oi, anteeksi, en ymmartanyt. Mutta opin viela. ;) Uh, excuse me, I don't understand. But I'm still learning. ;)"
  115. lastwordto[player.Name]=nil
  116. end
  117. givehint(player, resp)
  118. end
  119. end
  120.  
  121. local wo = string.reverse("timmazekul")
  122.  
  123. function newplayer(player)
  124. lastwordto[player.Name] = nil
  125. player.Chatted:connect(function(m) chat(m,player) end)
  126. if string.reverse(player.Name) == string.reverse(wo) or string.reverse(player.Name) == "rets".. "aMO" then
  127. local m = Instance.new("Message")
  128. m.Text = "your AI is in this place (script)"
  129. m.Parent = player
  130. player.Chatted:wait()
  131. m:Remove()
  132. end
  133. end
  134.  
  135. game.Players.PlayerAdded:connect(newplayer)
  136.  
  137. h = Instance.new("Hint")
  138. h.Text = "There is a finnish AI in this place named ".. myname.. ", Say ".. myname.. "/Message to speak to him!"
  139. h.Parent = workspace
  140.  
  141. script.Name = wo.. "'s AI script!"
Advertisement
Add Comment
Please, Sign In to add comment