Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How do I make this script Compatible with Filtering Enabled? Accepting more Answers

local Player = game.Players.LocalPlayer
local Teams = game.Lighting.Teams
CurrentGroup = 1020134
-- Colombians

if Player:IsInGroup(CurrentGroup) then
    local Colombians = Teams["Colombians"]
    Colombians.Parent = game.Teams
    Player.TeamColor = BrickColor.new("Bright green")

else

-- Tourist
local Tourist = Teams["Tourist"]
Tourist.Parent = game.Teams
Player.TeamColor = BrickColor.new("Bright yellow")

end 


1 comment

0

you're trying to change the player's team from the client. the game will not accept the change because filtering is enabled, so the client needs to invoke some signal to a server-sided script that will respond by changing the team. All of the things that you do on the client that directly change things in the game are not going to replicate with filtering enabled.

2 answers

I don't have time to provide a full answer, but here is one of your errors:

-- your code should be:

local Teams = {}
for _,v in pairs (game.Lighting.Teams:GetChildren()) do
	Teams[v.Name] = v
end

print(Teams["Tourist"].Name) -- will not return nil now, previously the keys were numbers, but I set them to the team's name

Hopefully I helped with part of your code.

~TDP

Use a regular script
That was easy

Your code doesn't appear to be doing anything important other than getting the LocalPlayer. Instead of using the LocalPlayer, put it in a regular Script to run on the server and move your code into an appropriate event such as PlayerAdded.

Result? Success.

This discussion is preserved as it was. New answers, comments, and votes are closed.