Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Give Bright red Team Credits. Any help?

My script here resets the players/game, but don't worry about that. Before all of that happens I need the bright red team to be given credits, but I am not sure how...

Here is my script

game.Workspace.ChildAdded:connect(function(child) 

if child.Name == "HostageFree" then 
 wait(0.05)
--here is were they need to be given credits (200 of them)

wait(10)
local pl = game.Players:GetChildren()
for i=1,#pl do
pl[i].Character.Humanoid.Health = 0
game.Workspace.HostageFree:Remove()
end
end  
end) 

1 answer

✓ Accepted answer

That is very simple. You just need a for in pairs to detect people on Bright Red and give them their bounty. I also combined the below for loop inside the new one.

game.Workspace.ChildAdded:connect(function(child) 
if child.Name == "HostageFree" then --Wait is unneccesary
	for _,player in pairs(game.Players:GetPlayers()) do
		if player.TeamColor == BrickColor.Red() then 
			player.leaderstats.Credits = player.leaderstats.Credits + 200
		end
		player.Character.Humanoid.Health = 0 --You can also use player:LoadCharacter() instead to respawn them swiftly, but i'll leave you to choose instead.
	end
	wait(10)
	game.Workspace.HostageFree:Destroy()  --Remove() is deprecated, use Destroy() where possible instead
end)

3 comments

0

killing them changes there team color and removes the weapons they have

0

the leader stat is under points but the name on leaderboard is Credits, will that effect this script?

0

Helloooo?

This discussion is preserved as it was. New answers, comments, and votes are closed.