Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

The map script is not working or doing anything, just turned on filtering enabled, help?

Asked by 4 years ago

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.")

0
Can you please use a code block and indent the code? Also, try to only include the section of code where the problem may be occurring at pidgey 548 — 4y
0
^ I agree lol kittonlover101 201 — 4y
0
OK first off. Dude! There are such things as functions. You don't need to repeat code. It will lag your game up. kittonlover101 201 — 4y
0
setting filtering enabled didnt break it because filtering enabled was forced on all games regardless if its enabled or disabled a while ago. If any AnonymousDeveloper13 22 — 4y

1 answer

Log in to vote
0
Answered by 4 years ago

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.")
0
Sir, I will try to use this scriot and use the tips so I can ask better questions in the future. Thank you. I will keep you updated of if it works or not in the future. NeutralEnergy -1 — 4y
0
Hi kittonlover101, I tried the script it was not working. I wonder why, it seems like it should work but it is not, weird. I put the maps in replicated storage and the script you gave me in workspace. The only bad thing I got in the output is this 14:27:24.998 - Not running script because past shutdown deadline NeutralEnergy -1 — 4y
0
That has to due with a 'wait'. There must be a wait in the script that is too long. kittonlover101 201 — 4y
0
Also what line? kittonlover101 201 — 4y
View all comments (4 more)
0
I will figure out what line when I get home. Also, do you think I need a wait() after every dongoshishi? NeutralEnergy -1 — 4y
0
Hi Mr. kittonlover101, I think I made some progress. I realized I made a mistake in the beginning of the script which affected everything else including accidentally calling the player as p. I also realize I needed to delete the defaultson() and defaultsoff() function. This is what I received in the output. Hello World. Script loaded. NeutralEnergy -1 — 4y
0
I can't really help you any more. kittonlover101 201 — 4y
0
Might want to try a different one if it doesn't work. Or make your own. kittonlover101 201 — 4y
Ad

Answer this question