Hello everyone,
I have decided to start up a sfing clan but I have already been given the place and the scripts. This one script seems to irk me.
Side note: The game did NOT have filtering enabled on until I turned it on yesterday so is this what broke it?
The purpose of the script is to first of all, add a chat command where I can randomize teams, a command to end the map that is currently on, and to find the map in Lighting, and clone it into workspace so my group can sword fight in it.
If a kind soul can please explain what is wrong, that would be great, the output says nothing.
script.Parent = nil
admins = {"NeutralEnergy"} --names of people who can toggle maps (case sensative)
s1,s2,s3,s4 = workspace.B1,workspace.B2,workspace.R1,workspace.R2
defaults = {s1,s2,s3,s4}
crown,koth,cache,bastion,brick,narrow,pit,stone,train,cross,remains, meadows, temple, warzone = game.Lighting.Crown,game.Lighting.BastionKOTH,game.Lighting.Cache,game.Lighting.Bastion,game.Lighting.Bricktops,game.Lighting.Narrowgill,game.Lighting.Pitgrounds,game.Lighting.Stonebrick,game.Lighting.Trainyard,game.Lighting.Cross,game.Lighting.Remains,game.Lighting.Meadows,game.Lighting.Temple,game.Lighting.Warzone
maps = {crown,koth,cache,bastion,brick,narrow,pit,stone,train,cross,remains, meadows, temple, warzone}
for i = 1,#maps do maps[i].Parent = nil end
function playerisadmin(name)
for i = 1,#admins do
if admins[i] == name then
return true
end
end
return false end
function gp()
return game.Players:GetPlayers()
end
function defaultson()
for _,v in pairs(defaults) do
v.Parent = game.workspace
end
end
function defaultsoff()
for _,v in pairs(defaults) do
v.Parent = nil
end
end
function randomizeteams()
local function returnteammembers(team)
local members = 0
for _,v in pairs(gp()) do
if v.TeamColor == team.TeamColor then
members = members +1
end
end
return members end
local players = gp()
for _,v in pairs(players) do v.TeamColor = BrickColor.new("White") end
local team1 = {}
local done = false
for i = 1,#players do
if returnteammembers(game.Teams.Red) == math.ceil(#players/2) then
done = true
end
if not done then players[math.random(1,#players)].TeamColor = BrickColor.new("Bright red") end
end
for i = 1,#players do
if players[i].TeamColor == BrickColor.new("White") then players[i].TeamColor = BrickColor.new("Bright blue") end
end
end
_G.rt = function() randomizeteams() end --manual usage of randomizing teams
function alert(text,t)
if workspace:findFirstChild("ALERT") then workspace.ALERT.Parent = game.Lighting end
local m = Instance.new("Message",workspace)
m.Name = "ALERT"
m.Text = text
game:GetService("Debris"):AddItem(m,t)
end
ps = game:GetService("Players")
ps.PlayerAdded:connect(function(p)
repeat wait() until p
if p:IsInGroup(2779041) then --group admin
table.insert(admins,p.Name) --people in the group get their names added to admin table
end
p.Chatted:connect(function(msg)
if playerisadmin(p.Name) == false then return end
if msg:lower()=="!randomteams" then
randomizeteams()
alert("TEAMS RANDOMIZED",1)
elseif msg:lower()=="!end" and workspace:findFirstChild("CurrentSim") then
game.Workspace.CurrentSim:Destroy()
for _,v in pairs(gp()) do
v.TeamColor = BrickColor.new("White")
end
defaultson()
alert("ENDING",5)
elseif msg:lower()=="!open cache" and workspace:findFirstChild("CurrentSim") == nil then
local c = cache:clone()
c.Parent = game.Workspace
c.Name = "CurrentSim"
c:MakeJoints()
defaultsoff()
alert("CACHE LOADED",5)
elseif msg:lower()=="!open koth" and workspace:findFirstChild("CurrentSim") == nil then
local c = koth:clone()
c.Parent = game.Workspace
c.Name = "CurrentSim"
c:MakeJoints()
defaultsoff()
alert("BASTION_KOTH LOADED",5)
elseif msg:lower()=="!open bricktops" and workspace:findFirstChild("CurrentSim") == nil then
local c = brick:clone()
c.Parent = game.Workspace
c.Name = "CurrentSim"
c:MakeJoints()
defaultsoff()
alert("BRICKTOPS LOADED",5)
elseif msg:lower()=="!open pitgrounds" and workspace:findFirstChild("CurrentSim") == nil then
local c = pit:clone()
c.Parent = game.Workspace
c.Name = "CurrentSim"
c:MakeJoints()
defaultsoff()
alert("PITGROUNDS LOADED",5)
elseif msg:lower()=="!open crown" and workspace:findFirstChild("CurrentSim") == nil then
local c = crown:clone()
c.Parent = game.Workspace
c.Name = "CurrentSim"
c:MakeJoints()
defaultsoff()
alert("CROWN LOADED",5)
elseif msg:lower()=="!open narrowgill" and workspace:findFirstChild("CurrentSim") == nil then
local c = narrow:clone()
c.Parent = game.Workspace
c.Name = "CurrentSim"
c:MakeJoints()
defaultsoff()
alert("NARROWGILL LOADED",5)
elseif msg:lower()=="!open stonebrick" and workspace:findFirstChild("CurrentSim") == nil then
local c = stone:clone()
c.Parent = game.Workspace
c.Name = "CurrentSim"
c:MakeJoints()
defaultsoff()
alert("STONEBRICK LOADED",5)
elseif msg:lower()=="!open bastion" and workspace:findFirstChild("CurrentSim") == nil then
local c = bastion:clone()
c.Parent = game.Workspace
c.Name = "CurrentSim"
c:MakeJoints()
defaultsoff()
alert("BASTION LOADED",5)
elseif msg:lower()=="!open remains" and workspace:findFirstChild("CurrentSim") == nil then
local c = remains:clone()
c.Parent = game.Workspace
c.Name = "CurrentSim"
c:MakeJoints()
defaultsoff()
alert("REMAINS LOADED",5)
elseif msg:lower()=="!open meadows" and workspace:findFirstChild("CurrentSim") == nil then
local c = meadows:clone()
c.Parent = game.Workspace
c.Name = "CurrentSim"
c:MakeJoints()
defaultsoff()
alert("MEADOWS LOADED",5)
elseif msg:lower()=="!open trainyard" and workspace:findFirstChild("CurrentSim") == nil then
local c = train:clone()
c.Parent = game.Workspace
c.Name = "CurrentSim"
c:MakeJoints()
c.Base.CFrame = c.Base.CFrame + Vector3.new(0,8,0) --cframe fix
defaultsoff()
alert("TRAINYARD LOADED",5)
elseif msg:lower()=="!open cross" and workspace:findFirstChild("CurrentSim") == nil then
local c = cross:clone()
c.Parent = game.Workspace
c.Name = "CurrentSim"
c:MakeJoints()
defaultsoff()
alert("CROSS LOADED",5)
elseif msg:lower()=="!open temple" and workspace:findFirstChild("CurrentSim") == nil then
local c = temple:clone()
c.Parent = game.Workspace
c.Name = "CurrentSim"
c:MakeJoints()
defaultsoff()
alert("TEMPLE LOADED",5)
elseif msg:lower()=="!open warzone" and workspace:findFirstChild("CurrentSim") == nil then
local c = warzone:clone()
c.Parent = game.Workspace
c.Name = "CurrentSim"
c:MakeJoints()
defaultsoff()
alert("WARZONE LOADED",5)
end
end)
end)
print(script.Name.." loaded.")
Ok first off.
There are such things as functions!
You don't need to repeat the same line of code 100 times.
Second off. NEVER. NEVER. Put a map or model in lighting.
Put it in replicated storage instead.
I'm assuming you used a video for this right? Because this is old code.
I don't know if this will work, but it's worth a try.
script.Parent = nil local admins = {"NeutralEnergy"} --names of people who can toggle maps (case sensative) s1,s2,s3,s4 = workspace.B1,workspace.B2,workspace.R1,workspace.R2 local defaults = {s1,s2,s3,s4} local rs = game.ReplicatedStorage crown,koth,cache,bastion,brick,narrow,pit,stone,train,cross,remains, meadows, temple, warzone = rs.Crown,rs.BastionKOTH,rs.Cache,rs.Bastion,rs.Bricktops,rs.Narrowgill,rs.Pitgrounds,rs.Stonebrick,rs.Trainyard,rs.Cross,rs.Remains,rs.Meadows,rs.Temple,rs.Warzone local maps = {crown,koth,cache,bastion,brick,narrow,pit,stone,train,cross,remains, meadows, temple, warzone} for i = 1,#maps do maps[i].Parent = nil end function playerisadmin(name) for i = 1,#admins do if admins[i] == name then return true end end return false end function gp() return game.Players:GetPlayers() end function defaultson() for _,v in pairs(defaults) do v.Parent = game.workspace end end function defaultsoff() for _,v in pairs(defaults) do v.Parent = nil end end function randomizeteams() local function returnteammembers(team) local members = 0 for _,v in pairs(gp()) do if v.TeamColor == team.TeamColor then members = members +1 end end return members end local players = gp() for _,v in pairs(players) do v.TeamColor = BrickColor.new("White") end local team1 = {} local done = false for i = 1,#players do if returnteammembers(game.Teams.Red) == math.ceil(#players/2) then done = true end if not done then players[math.random(1,#players)].TeamColor = BrickColor.new("Bright red") end end for i = 1,#players do if players[i].TeamColor == BrickColor.new("White") then players[i].TeamColor = BrickColor.new("Bright blue") end end end _G.rt = function() randomizeteams() end --manual usage of randomizing teams function alert(text,t) if workspace:findFirstChild("ALERT") then workspace.ALERT.Parent = game.Lighting end local m = Instance.new("Message",workspace) m.Name = "ALERT" m.Text = text game:GetService("Debris"):AddItem(m,t) end ps = game:GetService("Players") ps.PlayerAdded:connect(function() repeat wait() until p if p:IsInGroup(2779041) then --group admin table.insert(admins,p.Name) --people in the group get their names added to admin table end local dongoshishi function thisisthefunction() local c = game.ReplicatedStorage:FindFirstChild(dongoshishi):Clone() c.Parent = game.Workspace c.Name = 'CurrentSim' c:MakeJoints() defaultsoff() alert(dongoshishi.. 'LOADED',5) end p.Chatted:connect(function(msg) if playerisadmin(p.Name) == false then return end if msg:lower()=="!randomteams" then randomizeteams() alert("TEAMS RANDOMIZED",1) elseif msg:lower()=="!end" and workspace:findFirstChild("CurrentSim") then game.Workspace.CurrentSim:Destroy() for _,v in pairs(gp()) do v.TeamColor = BrickColor.new('White') end defaultson() alert('ENDING',5) elseif msg:lower()=="!open cache" and workspace:findFirstChild('CurrentSim') == nil then dongoshishi = "cache" thisisthefunction() elseif msg:lower()=="!open koth" and workspace:findFirstChild('CurrentSim') == nil then dongoshishi = "koth" thisisthefunction() elseif msg:lower()=="!open bricktops" and workspace:findFirstChild('CurrentSim') == nil then dongoshishi = "bricktops" thisisthefunction() elseif msg:lower()=="!open pitgrounds" and workspace:findFirstChild('CurrentSim') == nil then dongoshishi = "pitgrounds" thisisthefunction() elseif msg:lower()=="!open crown" and workspace:findFirstChild('CurrentSim') == nil then dongoshishi = "crown" thisisthefunction() elseif msg:lower()=="!open narrowgill" and workspace:findFirstChild('CurrentSim') == nil then dongoshishi = "narrowgill" thisisthefunction() elseif msg:lower()=="!open stonebrick" and workspace:findFirstChild('CurrentSim') == nil then dongoshishi = "stonebrick" thisisthefunction() elseif msg:lower()=="!open bastion" and workspace:findFirstChild('CurrentSim') == nil then dongoshishi = "bastion" thisisthefunction() elseif msg:lower()=="!open remains" and workspace:findFirstChild('CurrentSim') == nil then dongoshishi = "remains" thisisthefunction() elseif msg:lower()=="!open meadows" and workspace:findFirstChild('CurrentSim') == nil then dongoshishi = "lower" thisisthefunction() elseif msg:lower()=="!open trainyard" and workspace:findFirstChild('CurrentSim') == nil then dongoshishi = "trainyard" thisisthefunction() elseif msg:lower()=="!open cross" and workspace:findFirstChild('CurrentSim') == nil then dongoshishi = "cross" thisisthefunction() elseif msg:lower()=="!open temple" and workspace:findFirstChild('CurrentSim') == nil then dongoshishi = "temple" thisisthefunction() elseif msg:lower()=="!open warzone" and workspace:findFirstChild('CurrentSim') == nil then dongoshishi = "warzone" thisisthefunction() end end) end) print(script.Name.." loaded.")