Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 6 years ago

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.

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.. User#20192 0 — 6y
0
Be happy. Upvoted you :P Aimarekin 345 — 6y
0
I upvoted too User#21527 0 — 6y
0
Please help... User#21527 0 — 6y
View all comments (2 more)
0
@ Danielp533 you have been downvoted due to your bad scripts a lot of which will not work. User#5423 17 — 6y
0
Can anyone answer this? Please... User#21527 0 — 6y

1 answer

Log in to vote
0
Answered by
Kblow1 53
6 years ago
Edited 6 years ago

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)
Ad

Answer this question