the only thing idk how to do is assign points that connect with the leaderboard...any help on just that section? oh and would it be a local script becuz it is only supposed to be activated by the person who touches?
Really Easy.
first you need to make a leaderbored and make sure name the leader status points
For example I using points
on the first line you want to a touch function
1 | function onTouched(part) |
Secound, you need to find the player.
1 | local h = part.Parent:findFirstChild( "Humanoid" ) --Humanoid is the player |
2 | if (h~ = nil ) then |
3 | local thisplr = game.Players:findFirstChild(h.Parent.Name) |
4 | if (thisplr~ = nil ) then |
Remember that leader bored you made? Time to find it in the player!
1 | local stats = thisplr:findFirstChild( "leaderstats" ) |
2 | if (stats~ = nil ) then |
let add a value!
1 | if (score~ = nil ) then |
2 | score.Value = score.Value + amnt |
Time to finsh up the script with connecting the mouse and let add a amount part :D
01 | amnt = 1 --how much you get for it |
02 | function onTouched(part) |
03 | local h = part.Parent:findFirstChild( "Humanoid" ) |
04 | if (h~ = nil ) then |
05 | local thisplr = game.Players:findFirstChild(h.Parent.Name) |
06 | if (thisplr~ = nil ) then |
07 | local stats = thisplr:findFirstChild( "leaderstats" ) |
08 | if (stats~ = nil ) then |
09 | local score = stats:findFirstChild( "Points" ) |
10 | if (score~ = nil ) then |
11 | score.Value = score.Value + amnt |
12 | end |
13 | end |
14 | end |
15 | script.Parent:remove() |
16 | end |
17 | end |
18 |
19 | script.Parent.Touched:connect(onTouched) |
That all hope this help :)
Are you asking for normal points or Player Points? If it's player points then here is what you need.
01 | -- declare service |
02 | local PointsService = Game:GetService( "PointsService" ) |
03 |
04 | -- Bind function to player added event |
05 | game.Players.PlayerAdded:connect( function (player) |
06 | -- Get total number of points the game has available |
07 | local pointsToAward = PointsService:GetAwardablePoints() |
08 | -- Get total number of points this game has already awarded to the player |
09 | local universeBalance = PointsService:GetGamePointBalance(player.userId) |
10 | -- Check if the game has points to award and if the player hasn't gotten any points yet. If both are true, then give the player a point. |
11 | if ( pointsToAward > 0 and universeBalance = = 0 ) then |
12 | PointsService:AwardPoints(player.userId, 1 ) |
13 | end |
14 | end ) |
15 |