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 7 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.

local debounce = false

script.Parent.Touched:connect(function(hit)
    if not debounce then
        debounce = true
        local look = hit.Parent:findFirstChild("BallHandler").Value
            local found = game.Players:findFirstChild(look)
            local cash = found:findFirstChild("leaderstats")
            cash['Shots Made'].Value = cash['Shots Made'].Value+1
            print("Gave +1 SM")
            wait(1)
        debounce = false
    end
end)

--this is what "BallHandler" is.

while wait() do
    plr=game.Players:FindFirstChild(script.Parent.Parent.Parent.Name)
    if plr then
        script.Parent.Value=plr.Name
    end
end

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 7 years ago

hehe got it

local debounce = false
local Points = 1

script.Parent.Touched:connect(function(hit)
    if not debounce then
        debounce = true
        local look = hit.Parent:findFirstChild("BallHandler").Value
            local found = game.Players:findFirstChild(look)
            local cash = found:findFirstChild("leaderstats")
            cash['Shots Made'].Value = cash['Shots Made'].Value+1
            print("Gave +1 SM")
            local pps = game:GetService("PointsService")
            if pps:GetAwardablePoints() >= 0 then
            pps:AwardPoints(found.userId, Points)
            wait(1)
        debounce = false
            end
    end
end)







Ad

Answer this question