I have a faction menu that allows you to create a team and automatically puts the local player in it, but I wanted to create a remove-team event that moves the team to a folder. I sent a parameter from the client to the server to find the team using FindFirstChild(), but I can’t find out why it isn’t finding the team.
Here’s my code:
Server
RemoveTeam.OnServerEvent:Connect(function(player, team)
print(team)
local Teams = game.Teams
local find = Teams:FindFirstChild(team)
find.Parent = Teams.NotInUse
end)
Client
script.Parent.MouseButton1Click:Connect(function()
local team = game.Players.LocalPlayer.Team
print(team)
game.ReplicatedStorage.Factions.RemoveTeam:FireServer(team)
wait()
script.Parent.Parent.Parent.Menu.Visible = false
end)
because since the variable find is a FindFirstChild, and the team doesn’t exist, it returns nil. Nil does not have a parent property. Try this: Server
RemoveTeam.OnServerEvent:Connect(function(player, team)
print(team)
local Teams = game:GetService("Teams")
local find = Teams:FindFirstChild(team)
if find then find.Parent = Teams.NotInUse; end
end)
This checks if it is nil, and if so, doesn’t do anything.