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

Leaderboard Help!

Asked by 11 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.

01game.Players.PlayerAdded:connect(function(player)
02 
03stats = Instance.new("IntValue",player)
04stats.Name = "leaderstats"
05 
06points = Instance.new("IntValue", stats)
07points.Name = "Cash"
08 
09 
10 
11end)

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

1 answer

Log in to vote
3
Answered by 11 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:

01local red = BrickColor.new("Bright red")
02local blue = BrickColor.new("Bright blue")
03local green = BrickColor.new("Bright green")
04 
05local bullet = script.Parent
06 
07bullet.Touched:connect(function (part)
08 
09    Cash_To_Add = 5
10 
11    local char = part.Parent -- Easy to get the character.
12 
13    local playertouched = game.Players:GetPlayerFromCharacter(part.Parent.Name) --Find the  player instance of the person hit.
14 
15    --Bad way to do this, but add a code into the shooter (that controls the clone of this script, shown later)
View all 36 lines...

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)

1--Put this code seen below inside of the onActivated() function.
2 
3local shooter = Instance.new("StringValue")
4shooter.Value = Tool.Parent.Name
5shooter.Parent = bullet --Make sure this is AFTER the part in the function where it says this:
6shooter.Name = "SHOOTER"
7 
8--"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