Yeah, title doesn't make sense a bit. So basically, I'm trying to make soemthing that takes the LocalPlayer who touched the part, and then finds what team they are on and prints that they are on the right/wrong team. I have this so far:
function touch(hit) if hit.Parent:FindFirstChild("Humanoid") ~= nil and hit.Parent.TeamColor == BrickColor.new("Bright red")then print("right team") end end script.Parent.Touched:connect(touch)
Sorry If I messed up, but any help will be good! Thanks!
Here is a tip that makes functions a lot less time consuming Instead of making
function touch(hit) end
and having to connect the function at the end of the script,You can just do this
Part.Touched:connect(function(hit) --Part being the part that you want to be touched. end)
To answer your question, you can just use GetPlayerFromCharacter()
Part.Touched:connect(function(hit) local player = game.Players:GetPlayerFromCharacter(hit.Parent) if hit.Parent:FindFirstChild("Humanoid") ~= nil and player.TeamColor == BrickColor.new("Bright red") then print("Right Team") else print("Wrong Team") end end)
--EDIT: The text editor didn't seem to wont to cooperate with me :P