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

The team-check when I touch a brick does not work. What is the problem?

I am trying to check if a player is in a team when they touch a brick.

local teams = game:GetService("Teams")
local teamKids = teams:WaitForChild("Kid")

script.Parent.Touched:Connect(function(prt)
	print("I got touched!")
	local chr = prt.Parent
	local plr = game.Players:GetPlayerFromCharacter(chr)
	if prt and chr and plr then
		print("The thing that touched me is a player!")
		if plr.Team == teamKids then
			print("The player that touched me is in the team 'KIDS'!")
		end
	end
end)

The output I get when I touch the brick:

I got touched!

The thing that touched me is a player!

The thing is it does not say I am in the team 'KIDS' even tho I am 100%. Can even see it in the leaderboard...

I can't seem to find what is wrong.

6 comments

2

i would awnser but when i do people send negative reviews and make me lose my rank..right now im in the negative 10..

0

Be happy. Upvoted you :P

0

I upvoted too

0

Please help...

0

@ Danielp533 you have been downvoted due to your bad scripts a lot of which will not work.

0

Can anyone answer this? Please...

1 answer

Hello! I hope this answers your question.. ENJOY

script.Parent.Touched:Connect(function()
local teams = game:GetService("Teams"):GetTeams()
local plr = game:GetService("Players").LocalPlayer.Character
	for i,team in pairs(teams) do
   	 	local players = team:GetPlayers()
    		print(plr.Name.." Is On Team "..team.Name)
	end
end)

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