When a team player touch another teams player they die

image
You can select how many players you’d like in your test server with this drop down menu. Then click ‘Start’.

hmmm

image

omg! how could i miss that?! (tired mom syndrome)… do i do a team test or local one?

omg! its a big mess!!! hahahahahaha

Hmm, ok, could you take a screenshot of your studio when you run it so I can try and understand what’s happening?

i think these are the only ones that isnt sound related

Ok this one looks interesting, do you mind taking a screenshot of this localscript so I can see the error

game.Players.PlayerAdded:Connect(function(player)
local leaderstats = Instance.new(“Folder”)
leaderstats.Name = “leaderstats”
leaderstats.Parent = player

local coins = Instance.new("IntValue")
coins.Name = "Coins"
coins.Parent = leaderstats

local kills = Instance.new("IntValue")
kills.Name = "Kills"
kills.Parent = leaderstats

local deaths = Instance.new("IntValue")
deaths.Name = "Deaths"
deaths.Parent = leaderstats

while wait(1) do
	player:WaitForChild("leaderstats"):WaitForChild("Coins").Value += 10
end

end)

Players.PlayerAdded:connect(function(Player)
wait(1)
local Stats = Template:Clone()
Stats.Parent = Player
local Deaths = Stats.Deaths
Player.CharacterAdded:connect(function(Character)
Deaths.Value = Deaths.Value + 1
local Humanoid = Character:FindFirstChild(“Humanoid”)
if Humanoid then
Humanoid.Died:connect(function()
for i, Child in pairs(Humanoid:GetChildren()) do
if Child:IsA(‘ObjectValue’) and Child.Value and Child.Value:IsA(‘Player’) then
local Killer = Child.Value
if Killer:FindFirstChild(‘leaderstats’) and Killer.leaderstats:FindFirstChild(“Kills”) then
local Kills = Killer.leaderstats.Kills
Kills.Value = Kills.Value + 1
end
return
end
end
end)
end
end)
end)

its my leaderboard… i cant figure out how to fix it

Hmm okay in regards to the localscript I provided you, could you add a print statement to the top of the script just to confirm that it is running

hmm… wdym?? im so sorry but i really dont know anything about this

Computerguy2 wants you to add something like this to the very start of the script

print("The team touch script is running")

and then show the output of the game when it’s running, or just tell us if it shows up in the output.

Yep, Exactly like this.

Something to confirm that the script is running

16:46:28.239 The team touch script is running - Client - LocalScript:1

1 Like

does it matter that i have 3 teams? does that change anything?

Ok that confirms it is running. I have edited my local script code to have some print statements replace the old local script code with this one and tell me what is outputted.

local players = game:GetService("Players")
local deadEvent = game:GetService("ReplicatedStorage"):WaitForChild("DeadEvent")

local localplayer = players.LocalPlayer

local char = localplayer.Character or localplayer:WaitForChild("Character")

char.Humanoid.Touched:Connect(function(otherpart)
	
	print("something has been touched")
	
	if otherpart.Parent:FindFirstChild("Humanoid") and localplayer.Team.Name == "Police" then
		
		local otherplayer = players:GetPlayerFromCharacter(otherpart.Parent)
		
		if otherplayer.Team.Name == "Theif" then
			
			print(otherplayer.Name)
			
			deadEvent:FireServer(otherplayer)
			
		end
		
		
	end
	
end)

No, not necessarily, but just to rule any issue with the teams can you screenshot the teams you have made on the Explorer.

For example I have named mine differently
image

team

16:54:09.115 Stack Begin - Studio
16:54:09.115 Script ‘Players.Player1.PlayerScripts.LocalScript’, Line 13 - Studio - LocalScript:13
16:54:09.115 Stack End - Studio