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

Player Points From Tool Instead of Player?

Asked by 8 years ago

So this was a revision for my other question I answered, but basically how can I obtain player points through a tool that I have equipped? Here are the two scripts.

--this is where the tool will hit.

01local debounce = false
02 
03script.Parent.Touched:connect(function(hit)
04    if not debounce then
05        debounce = true
06        local look = hit.Parent:findFirstChild("BallHandler").Value
07            local found = game.Players:findFirstChild(look)
08            local cash = found:findFirstChild("leaderstats")
09            cash['Shots Made'].Value = cash['Shots Made'].Value+1
10            print("Gave +1 SM")
11            wait(1)
12        debounce = false
13    end
14end)

--this is what "BallHandler" is.

1while wait() do
2    plr=game.Players:FindFirstChild(script.Parent.Parent.Parent.Name)
3    if plr then
4        script.Parent.Value=plr.Name
5    end
6end

How would I make it so that I would get 1 Player Point whenever I touched that part with the tool I'm using?

Thanks, LukeGabrieI

1 answer

Log in to vote
0
Answered by 8 years ago

hehe got it

01local debounce = false
02local Points = 1
03 
04script.Parent.Touched:connect(function(hit)
05    if not debounce then
06        debounce = true
07        local look = hit.Parent:findFirstChild("BallHandler").Value
08            local found = game.Players:findFirstChild(look)
09            local cash = found:findFirstChild("leaderstats")
10            cash['Shots Made'].Value = cash['Shots Made'].Value+1
11            print("Gave +1 SM")
12            local pps = game:GetService("PointsService")
13            if pps:GetAwardablePoints() >= 0 then
14            pps:AwardPoints(found.userId, Points)
15            wait(1)
16        debounce = false
17            end
18    end
19end)
Ad

Answer this question