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

Help with the chatted event? [UNANSWERED]

Asked by 10 years ago

Everything here works except line 8/9, where I gave my best shot at trying to find the userId of the player that I wanted to give it to. Any ideas how to give them the points?

Ex: In game I would say '/points cardboardrocks' and it would give cardboardrocks 1 PP (The bolded thing: :AwardPoints(b, **1**)

keyword = "/points"

game.Players.PlayerAdded:connect(function(player)
    player.Chatted:connect(function(msg)
        if string.find(msg:lower(), keyword) then
            print("Found "..keyword)
            a = msg:sub(8, msg:len())
            print(a)
            playerschildren = game.Players:GetChildren()
            for i = 1, #playerschildren do
                if playerschildren[i].Name == a then
                    b = playerschildren[i].userId
                    print(b)
                end
            end
            game:GetService("PointsService"):AwardPoints(b, 1)
        end
    end)
end)

2 answers

Log in to vote
0
Answered by
JoLLDS 5
10 years ago

You should to do it:

/awarp [player name] [how much of points]

awarp = AWARd Points

Example: /awarp JoLLDS 50 = will give 50 PlayerPoints to JoLLDS

Do it:

keyword = "/awarp"

game.Players.PlayerAdded:connect(function(player)
    player.Chatted:connect(function(msg)
        if string.find(msg:lower(), keyword) then
            print("Found "..keyword)
            a = msg:sub(6, msg:len())
            print(a)
            playerschildren = game.Players:GetChildren()
            for i = 1, #playerschildren do
                if playerschildren[i].Name == a then
                    b = playerschildren[i].userId
                    print(b)
                end
            end
        a = msg:sub(6 + #playerschildren[i].Name + 1, msg:len())
            game:GetService("PointsService"):AwardPoints(b, a)
        end
    end)
end)

Warning: this script was untested, so, a error can be caused, pay attention on the Output window

0
Well I don't know how to do that, so once you tell me how then I can do it. CardboardRocks 215 — 10y
0
Done, i edit my answer, now see if works :P JoLLDS 5 — 10y
Ad
Log in to vote
-1
Answered by
Vividex 162
10 years ago

Both of the scripts above would not work because the server doesn't know how many points is awardable!

~100 bottles of bloxy cola on the wall

Answer this question