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

I need help with tables?

so i made a script on tables and this is what i came up ( i got it from freemodels then modified it a bit so im actually trying to learn how to script plss dont sue me from copying it @_@)

ppl = 1
		repeat
			ppl = ppl + 1
			p = game.Players:GetChildren()
			team2 = {}
			team3 = {}
			for num, obj in pairs(p) do
				if obj then
					if obj.PlayerGui.Play.Alive.Value then
						if obj.TeamColor == BrickColor.new("Bright red") then
							table.insert (team2,obj)
						elseif obj.TeamColor == BrickColor.new("Bright blue") then
							table.insert (team3,obj)
						end
					end
				end

so it is possible to make a script where in if player in team3 touched a part named blah blah blah(only team3 can touch it) then blah blah happens? if yes so how? ow and where can i learn scripting?

2 comments

0

What happens if it isn't a person from Team3

0

nothing happens.

1 answer

✓ Accepted answer

To do what you wanted to do you wouldn't need to use a table at all. To achieve what you've asked you simply need to use the Touched event and an if statement. An example is shown below.

script.Parent.Touched:connect(function(Part) --// Anonymous function 
	local Player = game.Players:GetPlayerFromCharacter(Part.Parent) --// Getting the player object associated with the touched part's parent - If there isn't one this variable will be nil later on when used.
	if Player and Player.TeamColor == BrickColor.new("Bright blue") then --// Checks if the player variable isn't nil, and checks whether their TeamColor is the Bright blue brickcolor. 
		print("The player is real, and their team is blue.") 
	end --// Ending the if statement
end) --// Anonymous function end

To learn more about scripting, take a look at the ROBLOX Wiki, or alternatively look around online or on the ROBLOX forums.

2 comments

0

really helped thanks :D.. ow and i forgot to mention that the script is in workspace ;-;..btw is it possible to have a script like this in workspace not in a part?

0

Yes. You just need to change the 'script.Parent' to point to the part in Workspace. For example, Workspace.ThePart.Touched

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