local debounce = false
local seat = script.Parent
print(script.Parent.Parent.CoreFolder.TeamID.Value)
seat.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") and hit.Parent.CoreFolder.TeamID == script.Parent.Parent.CoreFolder.TeamID.Value and not debounce then
debounce = true
print("match found")
return
end
if hit.Parent:FindFirstChild("Humanoid") and hit.Parent.CoreFolder.TeamID ~= script.Parent.Parent.CoreFolder.TeamID.Value and not debounce then
debounce = true
print("no match found")
hit.Parent.Humanoid.Health = 0
end
end)
the problem might be right under my nose, but if both TeamID values are a match they should not kill the player but only if both TeamID values dont match the player should die.
the player dies regardless if they both match or not.
Consider setting up your code like this:
local Debounce = false
local Seat = script.Parent
local function OnTouched(Hit)
if Hit.Parent:FindFirstChild("Humanoid") then
if not Debounce then
if Hit.Parent:FindFirstChild("Humanoid") then
Debounce = true
if Hit.Parent.CoreFolder.TeamID.Value == script.Parent.Parent.CoreFolder.TeamID.Value then
--code
Debounce = false
else
Hit.Parent.Humanoid.Health = 0
Debounce = false
end
end
end
end
end
Seat.Touched:Connect(OnTouched)
You’re checking a TeamID
against a TeamID.Value
, just add a .Value
to script.Parent.Parent.CoreFolder.TeamID
.
I knew it was something I missed, thanks for pointing it out.
Also, if this is just teams, you can use Roblox’s built-in Teams
service and store an ObjectValue
referencing the player’s .Team
there:
local Players = game:GetService("Players")
local dead = Enum.HumanoidStateType.Dead
local debounce = false
local seat = script.Parent
seat.Touched:Connect(function(hit)
local char = hit.Parent
local player = Players:GetPlayerFromCharacter(char)
local humanoid = char:FindFirstChildWhichIsA("Humanoid")
if player and humanoid and not debounce then
debounce = true
--seat.Team is an ObjectValue referencing the Team in Teams
if player.Team == seat.Team.Value then
print("match found")
--code here
debounce = false
else
print("no match found")
humanoid:SetState(dead)
--code here
debounce = false
end
end
end)
It might not be very aesthetic though in the player roster, so beware.
I use the team service too, the purpose of TeamID is to give things like vehicles,projectiles,players,etc a team ID so they can be identified as owned by blue team or red team.
1 Like
It seems like my suggestion is relevant to you then! Try using it, as it may save you a little time from all this CoreFolder
nonsense.