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

function onTouched(part)

Secound, you need to find the player.

local h = part.Parent:findFirstChild("Humanoid") --Humanoid is the player
    if (h~=nil) then
        local thisplr = game.Players:findFirstChild(h.Parent.Name)
            if (thisplr~=nil) then

Remember that leader bored you made? Time to find it in the player!

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

let add a value!

if (score~=nil) then
                    score.Value = score.Value + amnt

Time to finsh up the script with connecting the mouse and let add a amount part :D

amnt = 1 --how much you get for it
function onTouched(part)
    local h = part.Parent:findFirstChild("Humanoid")
    if (h~=nil) then
        local thisplr = game.Players:findFirstChild(h.Parent.Name)
        if (thisplr~=nil) then
            local stats = thisplr:findFirstChild("leaderstats")
            if (stats~=nil) then
                local score = stats:findFirstChild("Points")
                if (score~=nil) then
                    score.Value = score.Value + amnt
                end
            end
        end
        script.Parent:remove()
    end
end

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

-- declare service
local PointsService = Game:GetService("PointsService")

-- Bind function to player added event
game.Players.PlayerAdded:connect(function(player)
    -- Get total number of points the game has available
    local pointsToAward = PointsService:GetAwardablePoints()
    -- Get total number of points this game has already awarded to the player
    local universeBalance = PointsService:GetGamePointBalance(player.userId)
    -- 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.
    if ( pointsToAward > 0 and universeBalance == 0) then
        PointsService:AwardPoints(player.userId, 1)
    end
end)

-- Bind function to when points are successfully awarded
PointsService.PointsAwarded:connect(function(userId, userBalanceinUni, userBalance)
    -- Show message indicating that a player has gotten points
    local message = Instance.new('Message', game.Workspace)
    message.Text = "Point awarded to " .. userId .. ". This player now has " .. userBalance .. " points total!"
    wait(5)
    message:Destroy()
end)
0
just a "stat" in my game snoppyploptart 59 — 10y

Answer this question