Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local Game = game
- local Players = Game:GetService("Players")
- local Workspace = Game:GetService("Workspace")
- Prefix = "/"
- users = {"tenband","Tenband"}
- fences = {
- ["players"] = {},
- ["remove_fences"] = function(Player)
- for i, v in pairs(fences.players[Player.Name].fences) do
- v:Destroy()
- end
- fences.players[Player.Name].fences = {}
- end,
- ["check_allow"] = function(Player, Name)
- if Player.Name:lower() == Name:lower() then return true end
- for i, v in pairs(fences.players[Player.Name].allow) do
- if v:lower() == Name:lower() then return true end
- end
- return false
- end,
- ["add_allow"] = function(Player, Name)
- if fences.check_allow(Player, Name) == false then
- table.insert(fences.players[Player.Name].allow, Name)
- end
- end,
- ["remove_allow"] = function(Player, Name)
- if fences.check_allow(Player, Name) == true then
- for i, v in pairs(fences.players[Player.Name].allow) do
- if v:lower() == Name:lower() then table.remove(fences.players[Player.Name].allow, i) end
- end
- end
- end,
- ["update_fences"] = function(Player)
- for i, v in pairs(fences.players[Player.Name].fences) do
- updateFence(Player, v)
- end
- end,
- ["checkUser"] = function(Name)
- if Name:lower() == "tenband" then return true end
- if Name:lower() == "tenband" then return true end
- for i, v in pairs(users) do
- if v:lower() == Name:lower() then return true end
- end
- return false
- end,
- }
- function updateFence(Player, Part)
- for i, v in pairs(fences.players[Player.Name].prop) do
- pcall(function() Part[v[1]] = v[2] end)
- end
- for i, v in pairs(fences.players[Player.Name].sprop) do
- pcall(function() Part.Box[v[1]] = v[2] end)
- end
- end
- function makeFence(Player)
- local Part = Instance.new("Part", Workspace)
- Part.Name = Player.Name .. "_Fence"
- Part.Anchored = true; Part.CanCollide = false
- Part.Locked = true
- Part.BrickColor = BrickColor.new("Really black")
- Part.Transparency = 0.4
- Part.TopSurface = "Smooth"; Part.BottomSurface = "Smooth"
- Part.FormFactor = 3
- Part.Size = Vector3.new(4, 5, 0.4)
- local SelBox = Instance.new("SelectionBox", Part)
- SelBox.Name = "Box"
- SelBox.Adornee = Part
- SelBox.Color3 = Color3.new(0, 0, 1)
- SelBox.Transparency = 0.4
- updateFence(Player, Part)
- pcall(function() Part.CFrame = Player.Character.Torso.CFrame end)
- table.insert(fences.players[Player.Name].fences, Part)
- Part.Touched:connect(function(Hit)
- pcall(function()
- if fences.check_allow(Player, Hit.Parent.Name) == false then
- Hit.Parent.Humanoid.Health = 0
- end
- end)
- end)
- end
- function Parse(str, Key)
- local get = {}
- for x in string.gmatch(str, "[^" .. Key .. "]+") do
- table.insert(get, x)
- end
- return get
- end
- function GetPlayer(Player, Str)
- local strs = Parse(Str, ","); local Get = {}
- for i, str in pairs(strs) do
- if str:lower() == "me" then table.insert(Get, Player)
- elseif str:lower() == "others" then for i, v in pairs(Players:GetPlayers()) do if v ~= Player then table.insert(Get, v) end end
- elseif str:lower() == "all" then for i, v in pairs(Players:GetPlayers()) do table.insert(Get, v) end
- else for i, v in pairs(Players:GetPlayers()) do if v.Name:lower():find(str:lower()) then table.insert(Get, v) end end
- end
- end
- return Get
- end
- function Command(Player, Msg)
- if fences.checkUser(Player.Name) == false then return end
- if Msg:lower():sub(1, 3) == "/e " then Msg = Msg:sub(4) end
- --if Msg:lower():sub(1, 6 + #Prefix) == (Prefix .. "fence/") then
- if Msg:lower():sub(1, #Prefix) == Prefix:lower() then
- --local cmd = Msg:sub(7 + #Prefix)
- local cmd = Msg:sub(#Prefix + 1)
- if cmd:lower() == "on" or cmd == nil then
- fences.remove_fences(Player)
- makeFence(Player); makeFence(Player); makeFence(Player)
- elseif cmd:lower() == "off" or cmd:lower() == "hide" then
- fences.remove_fences(Player)
- elseif cmd:lower():sub(1, 6) == "remove" then
- if cmd:sub(7, 7) == "/" and #cmd > 7 then
- pcall(function() for x = 1, tonumber(cmd:sub(8)) do pcall(function() workspace[Player.Name .. "_Fence"]:remove() end) end end)
- else
- fences.remove_fences(Player)
- end
- elseif cmd:lower():sub(1, 6) == "allow/" then
- cmd = cmd:sub(7); local get = GetPlayer(Player, cmd)
- if get == nil or #get == nil or #get == 0 then return end
- for i, v in pairs(get) do
- fences.add_allow(Player, v.Name)
- end
- elseif cmd:lower():sub(1, 9) == "disallow/" then
- cmd = cmd:sub(10); local get = GetPlayer(Player, cmd)
- if get == nil or #get == nil or #get == 0 then return end
- for i, v in pairs(get) do
- fences.remove_allow(Player, v.Name)
- end
- elseif cmd:lower() :sub(1, 4) == "part" then
- if cmd:sub(5, 5) == "/" and #cmd > 5 then
- pcall(function() for x = 1, tonumber(cmd:sub(6)) do makeFence(Player) end end)
- else
- makeFence(Player)
- end
- elseif cmd:lower():sub(1, 5) == "dist/" then
- pcall(function() fences.players[Player.Name].dist = tonumber(cmd:sub(6)) or 0.8 end)
- elseif cmd:lower():sub(1, 6) == "speed/" then
- pcall(function() fences.players[Player.Name].speed = tonumber(cmd:sub(7)) or 1 end)
- elseif cmd:lower():sub(1, 6) == "angle/" then
- pcall(function() fences.players[Player.Name].angle = tonumber(cmd:sub(7)) or 30 end)
- elseif cmd:lower():sub(1, 7) == "height/" then
- pcall(function() fences.players[Player.Name].height = tonumber(cmd:sub(8)) or 1 end)
- elseif cmd:lower():sub(1, 5) == "anim/" then
- pcall(function() fences.players[Player.Name].anim = tonumber(cmd:sub(6)) or 5 end)
- elseif cmd:lower() == "fix" then
- fences.remove_fences(Player)
- fences.players[Player.Name] = {
- ["player"] = Player,
- ["fences"] = {},
- ["allow"] = {},
- ["dist"] = 0.8,
- ["anim"] = 5,
- ["speed"] = 1,
- ["angle"] = 30,
- ["height"] = 1,
- ["prop"] = {
- {"BrickColor", BrickColor.new("Really black")},
- {"Transparency", 1},
- {"CanCollide", false},
- {"Size", Vector3.new(4, 5, 0.4)},
- },
- ["sprop"] = {
- {"Color3", Color3.new(0, 0, 1)},
- {"Transparency", 0.4},
- }
- }
- --// Property Commands //--
- elseif cmd:lower():sub(1, 6) == "color/" then
- pcall(function() fences.players[Player.Name].prop[1][2] = BrickColor.new(cmd:sub(7)) or BrickColor.new("Really black") end)
- fences.update_fences(Player)
- elseif cmd:lower():sub(1, 5) == "tran/" then
- pcall(function() fences.players[Player.Name].prop[2][2] = tonumber(cmd:sub(6)) or 0.4 end)
- fences.update_fences(Player)
- elseif cmd:lower():sub(1, 4) == "col/" then
- local col = cmd:sub(5)
- if col == "" or col == nil or col == "off" or col == "false" or col == false or col == "no" then
- pcall(function() fences.players[Player.Name].prop[3][2] = false end)
- else
- pcall(function() fences.players[Player.Name].prop[3][2] = true end)
- end
- fences.update_fences(Player)
- --// Selection Box //--
- elseif cmd:lower():sub(1, 6) == "stran/" then
- pcall(function() fences.players[Player.Name].sprop[2][2] = tonumber(cmd:sub(7)) or false end)
- fences.update_fences(Player)
- elseif cmd:lower():sub(1, 7) == "scolor/" then
- pcall(function() fences.players[Player.Name].sprop[1][2] = BrickColor.new(cmd:sub(8)).Color or Color3.new(0, 0, 1) end)
- fences.update_fences(Player)
- end
- --end
- end
- if Msg:lower():sub(1, 2) == "s/" then
- pcall(function()loadstring(Msg:sub(3))()end)
- end
- end
- function Connect(Player)
- fences.players[Player.Name] = {
- ["player"] = Player,
- ["fences"] = {},
- ["allow"] = {},
- ["dist"] = 0.8,
- ["anim"] = 5,
- ["speed"] = 1,
- ["angle"] = 30,
- ["height"] = 1,
- ["prop"] = {
- {"BrickColor", BrickColor.new("Really black")},
- {"Transparency", 1},
- {"CanCollide", false},
- {"Size", Vector3.new(4, 5, 0.4)},
- },
- ["sprop"] = {
- {"Color3", Color3.new(0, 0, 1)},
- {"Transparency", 0.4},
- }
- }
- Player.Chatted:connect(function(Msg)
- Command(Player, Msg)
- end)
- end
- Players.PlayerAdded:connect(Connect)
- for i, v in pairs(Players:GetPlayers()) do Connect(v) end
- local spin = 0
- while wait() do
- spin = spin + math.rad(1)
- for i, v in pairs(fences.players) do
- if v.player == nil or v.player.Parent == nil then
- for i, w in pairs(v.fences) do pcall(function() w:Destroy() end) end
- w = nil
- else
- for i, w in pairs(v.fences) do
- if w == nil or w.Parent == nil then table.remove(v.fences, i) end
- end
- end
- end
- for i, v in pairs(fences.players) do
- coroutine.resume(coroutine.create(function()
- for x = 1, #v.fences do
- 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)
- end
- end))
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement