Code;
local event = Instance.new("RemoteEvent")
event.Parent = game.ReplicatedStorage
event.Name = "RCL"
event.OnServerEvent:connect(function()
local gunsadded = false
local bricktops = game.ReplicatedStorage.Maps.Bricktops
for i,v in ipairs(game.Players:GetChildren()) do
v.CharacterAdded:connect(function(character)
if v.TeamColor == BrickColor.new("Sand red") or v.TeamColor == BrickColor.new("Sabd blue") then
if game.Workspace.CurrentMap:IsAncestorOf(game.ReplicatedStorage.Maps.Bricktops) then for i,x in ipairs(WeaponStorage.RCLWeapons:GetChildren()) do
if not gunsadded then
gunsadded = true
if x:IsA("Tool") then
x:Clone().Parent = v.Backpack
gunsadded = false
end
end
end
end
end
end)
end
Purpose;
The event gets all the players in the game, and checks if they're on either the Bright blue or Bright red team, and checks whether "Bricktops" is present within workspace.CurrentMap. If the players are on the blue and red teams and Bricktops is present, then it gives the players weapons every time they respawn.
Idea of what the problem is;
if game.Workspace.CurrentMap:IsAncestorOf(game.ReplicatedStorage.Maps.Bricktops) then
Notes;
RemoteEvent is fired in another script when a TextButton is clicked.
Everything was running somewhat smoothly last night until I added :IsAncestorOf
I also tried using :IsDescendantOf

1 comment
Line 9: Surely it should be "Sand blue" and not "Sabd blue"