I tried writing print
s but the only one that successfully sent a console message was the first one. What I am trying to make is a part that gives a value to the other team when touched. I do call the function later on in the script. I get no errors in the output whatsoever.
01 | local p = script.Parent |
02 | local w = workspace |
03 | local r = w.RedScore |
04 | local b = w.BlueScore |
05 |
06 | print "Variables" |
07 |
08 | function Touch(hit) |
09 | if hit.Parent:FindFirstChild( "Humanoid" ) then |
10 | print "Humanoid" |
11 | if hit.Parent.TeamColor = = BrickColor.new( "Bright blue" ) then |
12 | r = r + 1 |
13 | elseif |
14 | hit.Parent.TeamColor = = BrickColor.new( "Bright red" ) then |
15 | b = b + 1 |
16 | end |
17 | print "If" |
18 | end |
Thanks for helping. :)
This might work.
01 | local p = script.Parent |
02 | local w = workspace |
03 | local r = w.RedScore |
04 | local b = w.BlueScore |
05 |
06 | print "Variables" |
07 |
08 | function Touch(hit) |
09 | if hit.Parent:FindFirstChild( "Humanoid" ) then |
10 | print "Humanoid" |
11 | local Player = game.Players:GetPlayerFromCharacter(hit.Parent) |
12 | if Player.Team = = game.Teams.Blue then |
13 | r.Value = r.Value + 1 |
14 | elseif Player.Team = = game.Teams.Red then |
15 | b.Value = b.Value + 1 |
16 | end |
17 | print "If" |
18 | end |
19 | end |
You need to call the function on an event.
This should work.
01 | local p = script.Parent |
02 | local w = workspace |
03 | local r = w.RedScore |
04 | local b = w.BlueScore |
05 |
06 | print "Variables" |
07 |
08 | function Touch(hit) |
09 | if hit.Parent:FindFirstChild( "Humanoid" ) then |
10 | print "Humanoid" |
11 | if hit.Parent.TeamColor = = BrickColor.new( "Bright blue" ) then |
12 | r = r + 1 |
13 | elseif |
14 | hit.Parent.TeamColor = = BrickColor.new( "Bright red" ) then |
15 | b = b + 1 |