Making a terminal system

Hello, Im making a terminal capture system for my game and Its not working, whenever one of the team capture it, then It will change the color of the UI, Here are the scripts:

Local Script:

local PointA = game.Workspace:FindFirstChild("PointA")
local Replicated = game:GetService("ReplicatedStorage")
local Event = game.ReplicatedStorage.PointChangeUI
local PointPrecent = game.ReplicatedStorage:WaitForChild("PointAprecent")

PointA.Touched:Connect(function(hit)
	
	if hit:FindFirstChild("Humanoid") then
		print("Hello")
		if hit.Team.Name == "Russians" then
			
			Event:FireAllClients("ARussian")
			
		elseif hit.Team.Name == "Germans" then
			
			Event:FireAllClients("AGerman")
		
		end
		
	end
	
end)

Server Script:

local PointA = game.Workspace:FindFirstChild("PointA")
local Replicated = game:GetService("ReplicatedStorage")
local Event = game.ReplicatedStorage.PointChangeUI
local PointPrecent = game.ReplicatedStorage:WaitForChild("PointAprecent")

PointA.Touched:Connect(function(hit)
	
	if hit:FindFirstChild("Humanoid") then
		print("Hello")
		if hit.Team.Name == "Russians" then
			
			Event:FireAllClients("ARussian")
			
		elseif hit.Team.Name == "Germans" then
			
			Event:FireAllClients("AGerman")
		
		end
		
	end
	
end)

Currently, I have only Point A

To check the player’s team you should do:

if hit.Parent:FindFirstChild("Humanoid") then
    local teamColor = game:GetService("Players"):GetPlayerFromCharacter(hit.Parent).TeamColor
end

Assign colors to both teams and check it this way.

It’s not going to work because you’re looking for the Humanoid as a child of the part that touched your sensor. You need to search the touching part’s Parent for the Humanoid.

For future reference as well, please add what behavior you’re experiencing as well as what the output of the script tells you. Even if there is no output, please tell us that. It gives us much more information than “Help, it doesn’t work.”

1 Like

On top of that, this line searches for the Team property of the part which hit it, which doesn’t exist.
if hit.Team.Name == "Russians" then

That property only exists in the Player object which should be found using
local player = game:GetService("Players"):GetPlayerFromCharacter(hit.Parent)

1 Like

This won’t work because you’re calling :GetPlayerFromCharacter() on what would assumedly be a Model object. That function is part of the Players service, so to get the result you’re looking for, you’d have to do

local teamColor = game.Players:GetPlayerFromCharacter(hit.Parent).TeamColor

Of course, in good practice you would also verify that :GetPlayerFromCharacter(hit.Parent) returns a valid Player object before trying to index the TeamColor.

1 Like

Your solution does not work I tried almost everything to make it work, nothing,
No errors.

I updated the code using @ChiefWildin’s advice, have you tried that?