generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

Re: Detecting the players' team

Previous Thread :: Next Thread 
IanSplodge is not online. IanSplodge
Joined: 13 Aug 2012
Total Posts: 2686
25 Dec 2015 03:01 AM
For some reason, this always returns "Error":

capturable = true
function onTouch(part)
local human = part.Parent:findFirstChild("Humanoid")
local name = part.Parent.Name
if not human then return end
if game.Players[name].TeamColor == BrickColor.new("Black") then
if capturable == true then
capturable = false
script.Parent.Parent.InStand.Value = false
local FlagClone = script.Parent.Parent.ELFLAG:Clone()
script.Parent.Parent.ELFLAG.Transparency = 1
FlagClone.Parent = human.Parent
local weld = Instance.new("Weld",FlagClone)
weld.Part0 = human.Parent.Torso
weld.Part1 = FlagClone
weld.C0 = CFrame.new(-1,0,0.5)
weld.C0 = weld.C0 * CFrame.fromEulerAnglesXYZ(math.rad(0),math.rad(0),math.rad(30))
FlagClone.Anchored = false
local HasFlag = Instance.new("BoolValue",game.Players[name])
HasFlag.Value = true
HasFlag.name = "HasFlag"
end
elseif game.Players[name].TeamColor == BrickColor.new("Gold") then
print "Returning Flag"
else
print "Error"
end
end
script.Parent.Touched:connect(onTouch)

~IanSplodge, Destroyer of Souls.
Report Abuse
IanSplodge is not online. IanSplodge
Joined: 13 Aug 2012
Total Posts: 2686
25 Dec 2015 03:12 AM
The player can only ever be on the Gold or Black team, yet it still prints "Error" regardless. I fail to see what I'm doing wrong.

~IanSplodge, Destroyer of Souls.
Report Abuse
IanSplodge is not online. IanSplodge
Joined: 13 Aug 2012
Total Posts: 2686
25 Dec 2015 06:15 AM
bump

~IanSplodge, Destroyer of Souls.
Report Abuse
IanSplodge is not online. IanSplodge
Joined: 13 Aug 2012
Total Posts: 2686
25 Dec 2015 06:17 AM
The game is here: http://www.roblox.com/games/335394849/Fort-Tech-Test

~IanSplodge, Destroyer of Souls.
Report Abuse
OzzyFin is not online. OzzyFin
Joined: 07 Jun 2011
Total Posts: 3600
25 Dec 2015 06:47 AM
most likely a hat's/tool's handle is touching it

try these changes

local plr = game.Players:GetPlayerFromCharacter(part.Parent) or game.Players:GetPlayerFromCharacter(part.Parent.Parent)

...

if plr.TeamColor == BrickColor.new("Black") then
...
elseif plr.TeamColor == BrickColor.new("Gold") then
Report Abuse
OzzyFin is not online. OzzyFin
Joined: 07 Jun 2011
Total Posts: 3600
25 Dec 2015 06:49 AM
also throw that humanoid check out and check plr instead
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image