#Help plss
1 messages · Page 1 of 1 (latest)
well, when a player dies, i want the game detect which team is the player: Red or Blue. If its Blue and he died, gives a point for RedScore. if its Red and he died, gives a point for BlueScore.
@wary forge
do you have any method of finding out what team a player is on?
yes, it is in my script, but isnt working :/
please send over the block of code that doesnt work.
to figure out if a player has died you can check the ".Died" event in each players humanoid
local function handle_death(player)
local leaderstats = player:FindFirstChild("leaderstats")
if not leaderstats or not player.Team then return end
if player.Team.Name == "Blue" then
-- PUNTO PARA ROJO
for _, p in ipairs(Players:GetPlayers()) do
local ls = p:FindFirstChild("leaderstats")
if ls then
local Red = ls:FindFirstChild(RedStatName)
if Red then Red.Value += 1 end
end
end
print(player.Name .. " died. Point for red.")
elseif player.Team.Name == "Red" then
-- PUNTO PARA AZUL
for _, p in ipairs(Players:GetPlayers()) do
local ls = p:FindFirstChild("leaderstats")
if ls then
local Blue = ls:FindFirstChild(BlueStatName)
if Blue then Blue.Value += 1 end
end
end
print(player.Name .. " died. Point for blue.")
end and more later in the script: local function handle_character_added(character)
local humanoid = character:WaitForChild("Humanoid")
local died = false
humanoid.Died:Connect(function()
if died then return end
died = true
handle_death(player)
end)
end
here is
local function handledeath(player)
local leaderstats = player:FindFirstChild("leaderstats")
if not leaderstats or not player.Team then return end
if player.Team.Name == "Blue" then
-- PUNTO PARA ROJO
for , p in ipairs(Players:GetPlayers()) do
local ls = p:FindFirstChild("leaderstats")
if ls then
local Red = ls:FindFirstChild(RedStatName)
if Red then Red.Value += 1 end
end
end
print(player.Name .. " died. Point for red.")
elseif player.Team.Name == "Red" then
-- PUNTO PARA AZUL
for _, p in ipairs(Players:GetPlayers()) do
local ls = p:FindFirstChild("leaderstats")
if ls then
local Blue = ls:FindFirstChild(BlueStatName)
if Blue then Blue.Value += 1 end
end
end
print(player.Name .. " died. Point for blue.")
end and more later in the script: local function handle_character_added(character)
local humanoid = character:WaitForChild("Humanoid")
local died = false
humanoid.Died:Connect(function()
if died then return end
died = true
handle_death(player)
end)
end
fixed?
are you using this function?
send that block of code please.
local function handle_death(player)
local leaderstats = player:FindFirstChild("leaderstats")
if not leaderstats or not player.Team then return end
if player.Team.Name == "Blue" then
-- PUNTO PARA ROJO
for _, p in ipairs(Players:GetPlayers()) do
local ls = p:FindFirstChild("leaderstats")
if ls then
local Red = ls:FindFirstChild(RedStatName)
if Red then Red.Value += 1 end
end
end
print(player.Name .. " died. Point for red.")
elseif player.Team.Name == "Red" then
-- PUNTO PARA AZUL
for _, p in ipairs(Players:GetPlayers()) do
local ls = p:FindFirstChild("leaderstats")
if ls then
local Blue = ls:FindFirstChild(BlueStatName)
if Blue then Blue.Value += 1 end
end
end
print(player.Name .. " died. Point for blue.")
end
not the function. i mean't where you're calling the function
a mb
im spanish
wait
local function handle_character_added(character)
local humanoid = character:WaitForChild("Humanoid")
local died = false
humanoid.Died:Connect(function()
if died then return end
died = true
handle_death(player)
end)
end i thing here
beunos dias