How to get players server side

-- SERVER SCRIPT INSIDE SERVERSCRIPTSERVICE
---> services
local TweenService = game:GetService("TweenService")

---> variables
local ball = game.Workspace:WaitForChild("Ball")
local hitparts = script.Parent

local opart = game.Workspace:WaitForChild("O")


---> main
hitparts.Touched:Connect(function(hit)
	if game.Players:GetPlayerFromCharacter(hit.Parent.Parent).TeamColor == BrickColor.new("Really blue") then
		ball.CFrame = CFrame.new(opart.Position)
	end
end)
---> main
hitparts.Touched:Connect(function(hit)
    local character = hit.Parent
    local player = game.Players:GetPlayerFromCharacter(character)
    if player and player.TeamColor == BrickColor.new("Really blue").Color then
        ball.CFrame = CFrame.new(opart.Position)
    end
end)

The other user also suggested this, seems you didn’t add the check.

Good news no error but nothing happened

Oops, you must do hit.Parent.Parent

Sill not working----------------------------

Can you show tool in explorer?

Do you want the character to touch the object, or the tool?

Why are you trying to touch a service? Or am I misunderstanding something?

Screenshot 2023-10-09 at 10.05.14

The tool----------------------------------

Okay, do this then. Make the player variable so it does character.Parent, and just keep the character that is set to “hit.Parent”, so if character which is the tool and player is the teamcolor you want it to be then the ball with teleport.

---> main
hitparts.Touched:Connect(function(hit)
    local character = hit.Parent
    local player = game.Players:GetPlayerFromCharacter(character.Parent)
    if player and player.TeamColor == BrickColor.new("Really blue").Color then
        ball.CFrame = CFrame.new(opart.Position)
    end
end)

Could you show us the location of the server script through images?

Could you send me a screenshot of the teams properties

Try this:

---> main
hitparts.Touched:Connect(function(hit)
    local character = hitparts.Parent
    local player = game.Players:GetPlayerFromCharacter(character)
    if player and player.TeamColor == BrickColor.new("Really blue") then
        ball.CFrame = CFrame.new(opart.Position)
    end
end)

Nothing happened

Could you try the version I sent?

hitparts.Touched:Connect(function(Hit)
    local Character = Hit.Parent
    local Player = game:GetService("Players"):GetPlayerFromCharacter(Character)

    _ = Player and print(Player.TeamColor)
    if Player and Player.TeamColor == BrickColor.new("Really blue") then
       ball.CFrame = CFrame.new(opart.Position)
       warn("Teleported Ball!")
    end
end)

then show me console.

I did------------------------------------