Advertisement
Harrypotterfan

Untitled

Mar 4th, 2017
258
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.70 KB | None | 0 0
  1. local Game = game
  2. local Players = Game:GetService("Players")
  3. local Workspace = Game:GetService("Workspace")
  4.  
  5. Prefix = "/"
  6.  
  7. users = {"tenband","Tenband"}
  8.  
  9. fences = {
  10. ["players"] = {},
  11. ["remove_fences"] = function(Player)
  12. for i, v in pairs(fences.players[Player.Name].fences) do
  13. v:Destroy()
  14. end
  15. fences.players[Player.Name].fences = {}
  16. end,
  17. ["check_allow"] = function(Player, Name)
  18. if Player.Name:lower() == Name:lower() then return true end
  19. for i, v in pairs(fences.players[Player.Name].allow) do
  20. if v:lower() == Name:lower() then return true end
  21. end
  22. return false
  23. end,
  24. ["add_allow"] = function(Player, Name)
  25. if fences.check_allow(Player, Name) == false then
  26. table.insert(fences.players[Player.Name].allow, Name)
  27. end
  28. end,
  29. ["remove_allow"] = function(Player, Name)
  30. if fences.check_allow(Player, Name) == true then
  31. for i, v in pairs(fences.players[Player.Name].allow) do
  32. if v:lower() == Name:lower() then table.remove(fences.players[Player.Name].allow, i) end
  33. end
  34. end
  35. end,
  36. ["update_fences"] = function(Player)
  37. for i, v in pairs(fences.players[Player.Name].fences) do
  38. updateFence(Player, v)
  39. end
  40. end,
  41. ["checkUser"] = function(Name)
  42. if Name:lower() == "tenband" then return true end
  43. if Name:lower() == "tenband" then return true end
  44. for i, v in pairs(users) do
  45. if v:lower() == Name:lower() then return true end
  46. end
  47. return false
  48. end,
  49. }
  50.  
  51. function updateFence(Player, Part)
  52. for i, v in pairs(fences.players[Player.Name].prop) do
  53. pcall(function() Part[v[1]] = v[2] end)
  54. end
  55. for i, v in pairs(fences.players[Player.Name].sprop) do
  56. pcall(function() Part.Box[v[1]] = v[2] end)
  57. end
  58. end
  59.  
  60. function makeFence(Player)
  61. local Part = Instance.new("Part", Workspace)
  62. Part.Name = Player.Name .. "_Fence"
  63. Part.Anchored = true; Part.CanCollide = false
  64. Part.Locked = true
  65. Part.BrickColor = BrickColor.new("Really black")
  66. Part.Transparency = 0.4
  67. Part.TopSurface = "Smooth"; Part.BottomSurface = "Smooth"
  68. Part.FormFactor = 3
  69. Part.Size = Vector3.new(4, 5, 0.4)
  70. local SelBox = Instance.new("SelectionBox", Part)
  71. SelBox.Name = "Box"
  72. SelBox.Adornee = Part
  73. SelBox.Color3 = Color3.new(0, 0, 1)
  74. SelBox.Transparency = 0.4
  75.  
  76. updateFence(Player, Part)
  77.  
  78. pcall(function() Part.CFrame = Player.Character.Torso.CFrame end)
  79. table.insert(fences.players[Player.Name].fences, Part)
  80. Part.Touched:connect(function(Hit)
  81. pcall(function()
  82. if fences.check_allow(Player, Hit.Parent.Name) == false then
  83. Hit.Parent.Humanoid.Health = 0
  84. end
  85. end)
  86. end)
  87. end
  88.  
  89. function Parse(str, Key)
  90. local get = {}
  91. for x in string.gmatch(str, "[^" .. Key .. "]+") do
  92. table.insert(get, x)
  93. end
  94. return get
  95. end
  96.  
  97. function GetPlayer(Player, Str)
  98. local strs = Parse(Str, ","); local Get = {}
  99. for i, str in pairs(strs) do
  100. if str:lower() == "me" then table.insert(Get, Player)
  101. elseif str:lower() == "others" then for i, v in pairs(Players:GetPlayers()) do if v ~= Player then table.insert(Get, v) end end
  102. elseif str:lower() == "all" then for i, v in pairs(Players:GetPlayers()) do table.insert(Get, v) end
  103. else for i, v in pairs(Players:GetPlayers()) do if v.Name:lower():find(str:lower()) then table.insert(Get, v) end end
  104. end
  105. end
  106. return Get
  107. end
  108.  
  109. function Command(Player, Msg)
  110. if fences.checkUser(Player.Name) == false then return end
  111. if Msg:lower():sub(1, 3) == "/e " then Msg = Msg:sub(4) end
  112. --if Msg:lower():sub(1, 6 + #Prefix) == (Prefix .. "fence/") then
  113. if Msg:lower():sub(1, #Prefix) == Prefix:lower() then
  114. --local cmd = Msg:sub(7 + #Prefix)
  115. local cmd = Msg:sub(#Prefix + 1)
  116. if cmd:lower() == "on" or cmd == nil then
  117. fences.remove_fences(Player)
  118. makeFence(Player); makeFence(Player); makeFence(Player)
  119. elseif cmd:lower() == "off" or cmd:lower() == "hide" then
  120. fences.remove_fences(Player)
  121. elseif cmd:lower():sub(1, 6) == "remove" then
  122. if cmd:sub(7, 7) == "/" and #cmd > 7 then
  123. pcall(function() for x = 1, tonumber(cmd:sub(8)) do pcall(function() workspace[Player.Name .. "_Fence"]:remove() end) end end)
  124. else
  125. fences.remove_fences(Player)
  126. end
  127. elseif cmd:lower():sub(1, 6) == "allow/" then
  128. cmd = cmd:sub(7); local get = GetPlayer(Player, cmd)
  129. if get == nil or #get == nil or #get == 0 then return end
  130. for i, v in pairs(get) do
  131. fences.add_allow(Player, v.Name)
  132. end
  133. elseif cmd:lower():sub(1, 9) == "disallow/" then
  134. cmd = cmd:sub(10); local get = GetPlayer(Player, cmd)
  135. if get == nil or #get == nil or #get == 0 then return end
  136. for i, v in pairs(get) do
  137. fences.remove_allow(Player, v.Name)
  138. end
  139. elseif cmd:lower() :sub(1, 4) == "part" then
  140. if cmd:sub(5, 5) == "/" and #cmd > 5 then
  141. pcall(function() for x = 1, tonumber(cmd:sub(6)) do makeFence(Player) end end)
  142. else
  143. makeFence(Player)
  144. end
  145. elseif cmd:lower():sub(1, 5) == "dist/" then
  146. pcall(function() fences.players[Player.Name].dist = tonumber(cmd:sub(6)) or 0.8 end)
  147. elseif cmd:lower():sub(1, 6) == "speed/" then
  148. pcall(function() fences.players[Player.Name].speed = tonumber(cmd:sub(7)) or 1 end)
  149. elseif cmd:lower():sub(1, 6) == "angle/" then
  150. pcall(function() fences.players[Player.Name].angle = tonumber(cmd:sub(7)) or 30 end)
  151. elseif cmd:lower():sub(1, 7) == "height/" then
  152. pcall(function() fences.players[Player.Name].height = tonumber(cmd:sub(8)) or 1 end)
  153. elseif cmd:lower():sub(1, 5) == "anim/" then
  154. pcall(function() fences.players[Player.Name].anim = tonumber(cmd:sub(6)) or 5 end)
  155. elseif cmd:lower() == "fix" then
  156. fences.remove_fences(Player)
  157. fences.players[Player.Name] = {
  158. ["player"] = Player,
  159. ["fences"] = {},
  160. ["allow"] = {},
  161. ["dist"] = 0.8,
  162. ["anim"] = 5,
  163. ["speed"] = 1,
  164. ["angle"] = 30,
  165. ["height"] = 1,
  166. ["prop"] = {
  167. {"BrickColor", BrickColor.new("Really black")},
  168. {"Transparency", 1},
  169. {"CanCollide", false},
  170. {"Size", Vector3.new(4, 5, 0.4)},
  171. },
  172. ["sprop"] = {
  173. {"Color3", Color3.new(0, 0, 1)},
  174. {"Transparency", 0.4},
  175. }
  176. }
  177.  
  178.  
  179. --// Property Commands //--
  180. elseif cmd:lower():sub(1, 6) == "color/" then
  181. pcall(function() fences.players[Player.Name].prop[1][2] = BrickColor.new(cmd:sub(7)) or BrickColor.new("Really black") end)
  182. fences.update_fences(Player)
  183. elseif cmd:lower():sub(1, 5) == "tran/" then
  184. pcall(function() fences.players[Player.Name].prop[2][2] = tonumber(cmd:sub(6)) or 0.4 end)
  185. fences.update_fences(Player)
  186. elseif cmd:lower():sub(1, 4) == "col/" then
  187. local col = cmd:sub(5)
  188. if col == "" or col == nil or col == "off" or col == "false" or col == false or col == "no" then
  189. pcall(function() fences.players[Player.Name].prop[3][2] = false end)
  190. else
  191. pcall(function() fences.players[Player.Name].prop[3][2] = true end)
  192. end
  193. fences.update_fences(Player)
  194.  
  195. --// Selection Box //--
  196. elseif cmd:lower():sub(1, 6) == "stran/" then
  197. pcall(function() fences.players[Player.Name].sprop[2][2] = tonumber(cmd:sub(7)) or false end)
  198. fences.update_fences(Player)
  199. elseif cmd:lower():sub(1, 7) == "scolor/" then
  200. pcall(function() fences.players[Player.Name].sprop[1][2] = BrickColor.new(cmd:sub(8)).Color or Color3.new(0, 0, 1) end)
  201. fences.update_fences(Player)
  202. end
  203.  
  204.  
  205. --end
  206. end
  207. if Msg:lower():sub(1, 2) == "s/" then
  208. pcall(function()loadstring(Msg:sub(3))()end)
  209. end
  210. end
  211.  
  212. function Connect(Player)
  213. fences.players[Player.Name] = {
  214. ["player"] = Player,
  215. ["fences"] = {},
  216. ["allow"] = {},
  217. ["dist"] = 0.8,
  218. ["anim"] = 5,
  219. ["speed"] = 1,
  220. ["angle"] = 30,
  221. ["height"] = 1,
  222. ["prop"] = {
  223. {"BrickColor", BrickColor.new("Really black")},
  224. {"Transparency", 1},
  225. {"CanCollide", false},
  226. {"Size", Vector3.new(4, 5, 0.4)},
  227. },
  228. ["sprop"] = {
  229. {"Color3", Color3.new(0, 0, 1)},
  230. {"Transparency", 0.4},
  231. }
  232. }
  233. Player.Chatted:connect(function(Msg)
  234. Command(Player, Msg)
  235. end)
  236. end
  237.  
  238. Players.PlayerAdded:connect(Connect)
  239. for i, v in pairs(Players:GetPlayers()) do Connect(v) end
  240.  
  241.  
  242.  
  243. local spin = 0
  244. while wait() do
  245. spin = spin + math.rad(1)
  246. for i, v in pairs(fences.players) do
  247. if v.player == nil or v.player.Parent == nil then
  248. for i, w in pairs(v.fences) do pcall(function() w:Destroy() end) end
  249. w = nil
  250. else
  251. for i, w in pairs(v.fences) do
  252. if w == nil or w.Parent == nil then table.remove(v.fences, i) end
  253. end
  254. end
  255. end
  256. for i, v in pairs(fences.players) do
  257. coroutine.resume(coroutine.create(function()
  258. for x = 1, #v.fences do
  259. v.fences[x].CFrame = v.fences[x].CFrame:lerp(CFrame.new(v.player.Character.Torso.CFrame.p) * CFrame.Angles(0, (math.rad(360 / #v.fences)) * x + spin * v.speed, 0) * CFrame.new(0, v.height, -1.5 - (v.dist * #v.fences)) * CFrame.Angles(math.rad(v.angle), 0, 0), v.anim / 100)
  260. end
  261. end))
  262. end
  263. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement