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.
local p = script.Parent local w = workspace local r = w.RedScore local b = w.BlueScore print"Variables" function Touch(hit) if hit.Parent:FindFirstChild("Humanoid")then print"Humanoid" if hit.Parent.TeamColor == BrickColor.new("Bright blue")then r = r + 1 elseif hit.Parent.TeamColor == BrickColor.new("Bright red")then b = b +1 end print"If" end
Thanks for helping. :)
This might work.
local p = script.Parent local w = workspace local r = w.RedScore local b = w.BlueScore print"Variables" function Touch(hit) if hit.Parent:FindFirstChild("Humanoid") then print"Humanoid" local Player = game.Players:GetPlayerFromCharacter(hit.Parent) if Player.Team == game.Teams.Blue then r.Value = r.Value + 1 elseif Player.Team == game.Teams.Red then b.Value = b.Value +1 end print"If" end end
You need to call the function on an event.
This should work.
local p = script.Parent local w = workspace local r = w.RedScore local b = w.BlueScore print"Variables" function Touch(hit) if hit.Parent:FindFirstChild("Humanoid")then print"Humanoid" if hit.Parent.TeamColor == BrickColor.new("Bright blue")then r = r + 1 elseif hit.Parent.TeamColor == BrickColor.new("Bright red")then b = b +1 end print"If" end end script.Parent.Touched:Connect(Touch)