Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

Leaderboard Help!

Asked by 10 years ago

I am looking for a script that adds a certain amount of points when you kill someone from a certain team.

Example: 3 Teams: Red, Blue, and Green. Red will only get points for killing Blue but NOT Green. Then Blue and Green are not able to earn points at all from killing.

Does anyone know a script that allows this? NOTE: Red, Blue, and Green ARE NOT the actual team names so make sure you point out what I need to change so it fits my needs.

game.Players.PlayerAdded:connect(function(player)

stats = Instance.new("IntValue",player)
stats.Name = "leaderstats"

points = Instance.new("IntValue", stats)
points.Name = "Cash"



end)

This is my leaderboard script. Add/Edit anything you need to fit my needs. Thnx!

1 answer

Log in to vote
3
Answered by 10 years ago

Okay... I think I have a basic idea. So like you said, I will refer to the teams as Red, Blue, and Green. I will use a TeamColor (BrickColor) for the team colors.

Your script looks good so far, but in order to find the player that was killed, you need to go into the weapon bulletscript (the one that clones INTO the bullet) and add something like this:


local red = BrickColor.new("Bright red") local blue = BrickColor.new("Bright blue") local green = BrickColor.new("Bright green") local bullet = script.Parent bullet.Touched:connect(function (part) Cash_To_Add = 5 local char = part.Parent -- Easy to get the character. local playertouched = game.Players:GetPlayerFromCharacter(part.Parent.Name) --Find the player instance of the person hit. --Bad way to do this, but add a code into the shooter (that controls the clone of this script, shown later) local charthatshot = script.Parent.SHOOTER.Value local findchar = game.Workspace:findFirstChild(charthatshot) if findchar ~= nil then local shootingPlayer = game.Players:GetPlayerFromCharacter(findChar.Name) local stats = shootingPlayer:findFirstChild("leaderstats") if stats ~= nil then local money = stats:findFirstChild("Cash") end if shootingPlayer.TeamColor.Name == red then if playertouched.TeamColor.Name == blue and char.Humanoid.Health == 0 then money.Value = money.Value + Cash_To_Add elseif playertouched.TeamColor.Name == green money.Value = money.Value + 0 end elseif shootingPlayer.TeamColor.Name == blue then --Do what is above except your own conditions. end end end)

EDIT TO ABOVE: Fixed something: TeamColor itself is not a text value or a number value like brickcolor, so I fixed it by saying "TeamColor.Name" because that returns a text value.

Because there is that SHOOTER value on line 20 that I said you needed to make, here is the script to put into the shooter script (Like PaintballShooter in the Linked ROBLOX paintball gun)

--Put this code seen below inside of the onActivated() function.

local shooter = Instance.new("StringValue")
shooter.Value = Tool.Parent.Name
shooter.Parent = bullet --Make sure this is AFTER the part in the function where it says this:
shooter.Name = "SHOOTER"

--"bullet.Parent = game.Workspace" or something.

I know it is an (Time for my favorite line!) in-efficient, but working script, so I hope it works for you. Tell me if I messed up on anything!

--XanthicDragon, a fellow minor developer on ROBLOX

Ad

Answer this question