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 a developer team?

while wait() do
	if script.Parent.Parent.Players:FindFirstChild(JakePlays_TV) then
		script.Parent.Parent.Players.JakePlays_TV.Team = Developer 
	end
end

I tried to use this script to make it so that I am in the developer team automatically. Is there any suggestions as to what I did wrong? This script is in the ServerScriptService

4 answers

You're using a loop to check when ever JakePlays_TV appears inside of the Player's service. The way you're using FindFirstChild is technically wrong since you didn't use that as a string. FindFirstChild needs a string for it to search for a child called that.

If I wanted to find a part named Part in workspace:

local part = workspace:FindFirstChild("Part")

Instead of using an infinite while-loop, you could use PlayerAdded event which fires whenever a player joins the server. This event also provides us the joining player in it's parameter:

--Define services we are using.
local Players = game:GetService("Players")
local Teams = game:GetService("Teams")

Players.PlayerAdded:Connect(function(player)
	--We compare strings here. Strings need quote marks " "
	if player.Name == "JakePlays_TV" then
		--if player is you
		player.Team = Teams:FindFirstChild("Developer") --Notice we use quotes
	end
end)

Let me know if this is what you needed.

For first, you dont need to use script.Parent.Parent, only use "game" example:

game.Players:FindFirstChild("...")

also your FindFirstChild is incorrect, you need to use a string. example:

workspace:FindFirstChild("Part") -- use "ObjName" not ObjName (add quotes)

and is not a good way to use a loop to check, you can detect on player added make this. example:

game.Players.PlayerAdded:Connect(function(player)
	print("the player: " .. player.Name .. " joined!")
end)

also you can use a table and a generic for loop to make developers. example:

-- Team service / Your team
local teams = game:GetService("Teams")
local team = teams:FindFirstChild("Developer") -- Team location
-- Players service
local Players = game:GetService("Players")

local developers = {"JakePlays_TV"}
-- You can put more, only put ' ,"PLAYER_NAME" '

Players.PlayerAdded:Connect(function(player) -- Detect on player added and get player
	for _,devName in pairs(developers) do -- Get all "strings" in developers by one per one
		if devName == player.Name and team then -- Check if player is a dev / check if devName is equal to playerName and check if your team exist
			player.Team = team -- Set team
		end
	end
end)

Hope it helped :)

You forgot to add these "" around JakePlays_TV in FindFirstChild() so you should change it to FindFirstChild("JakePlays_TV")

You need the "" because FindFirstChild takes a string input

while wait() do
    if script.Parent.Parent.Players:FindFirstChild("JakePlays_TV") then
        script.Parent.Parent.Players.JakePlays_TV.Team = Developer 
    end
end

1 comment

0

Developer should also be a string

The problem is simple. You forgot to add "" in :FindFirstChild() . It should be :FindFirstChild("JakePlays_TV") .

And also, it is not a good way to use a while true do loop even though you can use a game.Players.PlayerAdded() function.

The better way to achieve the same thing will be:

game.Players.PlayerAdded:Connect(function(player)
	if player.Name == "JakePlays_TV" then
		player.Team = Developer
	end
end)

If this answered your question then don't forget to click that "Accept Answer" button. :)

1 comment

0

Developer should be a string

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