local Players = game:GetService("Players")
local Teams = game:GetService("Teams")
local debounce = true
game.Players.PlayerAdded:Connect(function(player)
if player.Team == Teams["Red Team"] then script.Parent.Touched:Connect(function(hit) local player = game:GetService("Players"):GetPlayerFromCharacter(hit.Parent) if player then debounce = false player.leaderstats.Points.Value += 1 wait(3) debounce = true end end) end
end)
You need to put the if statement within the Touched event; that way, it will check if the player is on 'Red Team' when they touch the part.
Also, the PlayerAdded event is unnecessary.
local Players = game:GetService("Players") local Teams = game:GetService("Teams") local debounce = false script.Parent.Touched:Connect(function(hit) local player = Players:GetPlayerFromCharacter(hit.Parent) if player and player.Team == Teams["Red Team"] then if debounce then return end -- If the debounce is active, it will return to the function, preventing the function from continuing. debounce = true player.leaderstats.Points.Value += 1 task.wait(3) debounce = false end end)