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

How do I make a script give points to ONLY the person who touched it?

Asked by 10 years ago

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?

0
id understand the point of a local script snoppyploptart 59 — 10y

2 answers

Log in to vote
2
Answered by 10 years ago

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

1function onTouched(part)

Secound, you need to find the player.

1local 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!

1local stats = thisplr:findFirstChild("leaderstats")
2    if (stats~=nil) then

let add a value!

1if (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

01amnt = 1 --how much you get for it
02function 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
17end
18 
19script.Parent.Touched:connect(onTouched)

That all hope this help :)

1
thx snoppyploptart 59 — 10y
0
Anytime you need anything else you can pm on here or roblox :) GuardainDev 45 — 10y
Ad
Log in to vote
0
Answered by 10 years ago

Are you asking for normal points or Player Points? If it's player points then here is what you need.

01-- declare service
02local PointsService = Game:GetService("PointsService")
03 
04-- Bind function to player added event
05game.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
14end)
15 
View all 23 lines...
0
just a "stat" in my game snoppyploptart 59 — 10y

Answer this question