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

Script to choose "team"?

I have a problem with this script, when i click the button(gui) if the id[d].Value ~= "none", it will make another gui visible but i need it to do this only if ALL the id[d].value ~= "none". Hope you understand

id are StringValue ui is a screengui

local id = game.Workspace.Guards:GetChildren()
local player = script.Parent.Parent.Parent.Parent.Parent
local ui = script.Parent.Parent.Parent.Parent.UI
local foundplayer = false

function OnClicked()
    for d = 1,  #id do
		if foundplayer == false then
		if id[d].Value == "None" then
			foundplayer = true
	        ui.Id.Value = id[d].Name
	        id[d].Value = player.Name
	local spawn = game.Workspace.GuSpawns:FindFirstChild("Spawn"..d)
	        ui.Team.Value = "Guards"
			        player.Character.Torso.CFrame = CFrame.new(Vector3.new(spawn.Position.x, spawn.Position.y + 3, spawn.Position.z))

	        local ui2 = ui:GetChildren()
	        for o = 1,#ui2 do
		        if ui2[o].ClassName == "Frame" then
		        ui2[o].Visible = true
		        end
		    end 
			   ui.Clock.Visible = true
			   ui.Character.Visible = false
			   ui.Crafting.Visible = false
			   ui.Sections.Character.Visible = false
			   ui.Sections.Crafting.Visible = false
	        script.Parent.Parent.Visible = false
	end
		if id[d].Value ~= "None" then
		    script.Parent.Parent.Full.Gu.Visible = true
		    wait(2)
		    script.Parent.Parent.Full.Gu.Visible = false
end
	end
end
foundplayer = false
end

script.Parent.MouseButton1Click:connect(OnClicked)

2 comments

1

This has Nothing related to "teams"

0

its not related to normal roblox teams, sorry i forgot to mention it!

1 answer

If you want it to check if all the values are "none", I recommend using a generic loop. Ex:

local id = game.Workspace.Guards:GetChildren()
AllNone = true

for i,v in pairs(id) do
	if v.Value ~= "none" then
		AllNone = false
	end
end)
-- Put an if statement, if AllNone is equal to false, and perform your function

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