Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Help with the chatted event? [UNANSWERED]

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

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

2 comments

0

Well I don't know how to do that, so once you tell me how then I can do it.

0

Done, i edit my answer, now see if works :P

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

This discussion is preserved as it was. New answers, comments, and votes are closed.