Touching part changes a objectvalue but not player team

Hello,

I am working on a tycoon; And whenever the player touches a door it should change the Owner value inside of the tycoon to the player, and change the team.

It does change the ObjectValue to the player but it does not change the team.

It’s in a Script:

local TouchPart = script.Parent

TouchPart.Touched:Connect(function(hitPart)
	if hitPart.Parent:FindFirstChild("Humanoid") then
		local Player = game:GetService("Players"):GetPlayerFromCharacter(hitPart.Parent)
		if game:GetService("ServerStorage"):WaitForChild("PlayerMoney"):FindFirstChild(Player.Name).TycoonOwned.Value == nil then
			if TouchPart.Parent.Parent.Parent.Owner.Value == nil then
				print("Change Team")
				Player.Team = game:GetService("Teams"):WaitForChild(hitPart.Parent.Parent.Parent.Name, 60)
				TouchPart.Parent.Parent.Parent.Owner.Value = Player
			end
		end
	end
end)

I have tried changing the TeamColor and it still does not work.

Is there an issue in my script or is this a bug?
It does not return any errors it all works but that.

Thanks in advance.

From what I see, the line where you set Player.Team doesn’t actually change the Player’s team to a specific team.

Yeah that’s the problem.

It has worked ever since today.


So do you know another method to change the team; as if I cant change the team I cant proceed.

Try using this:

Player.TeamColor = game:GetService("Teams"):WaitForChild(hitPart.Parent.Parent.Parent.TeamColor)

TeamColor is not the team object it’s a brickcolor.

Then change it to the brickcolor. It will switch the players team.