Untitled

 avatar
user_1052705
plain_text
a year ago
1.9 kB
8
Indexable
local nameOfUser = nil

function getFullName(FullName)
	local foundPlayer = nil
	
	local Players = game.Players:GetPlayers()
	for i= 1,#Players do
		local CurrentPlayer = Players[i]
		
		if string.lower(CurrentPlayer.Name):sub(1, #FullName) == string.lower(FullName) then
			foundPlayer = CurrentPlayer.Name
			break
		end
	end
	return foundPlayer
end

game.Players.PlayerAdded:Connect(function(Player)
	Player.Chatted:Connect(function(Chat)
		local MessageSplit = Chat:split(" ")
		local ChatUpper = string.lower(MessageSplit[1])
		if string.sub(ChatUpper, 0, string.len(":pg")) == ":pg" and Player:GetRankInGroup(0000) >= 000 then
			local NameOfPlayer = MessageSplit[2]
			getFullName(NameOfPlayer)
			nameOfUser = getFullName(NameOfPlayer)
			
			if game.Players:FindFirstChild(nameOfUser) then
				if nameOfUser ~= Player.Name then
					local Text = Chat:split(NameOfPlayer)[2]
					game.Players:FindFirstChild(nameOfUser).leaderstats.Points.Value += Text
					
					Player.PlayerGui.PointsNotif.Display.Text = "SUCCESSFULLY GIVEN "..Text.." POINTS TO "..string.upper(nameOfUser).."!"
					game.Players:FindFirstChild(nameOfUser).PlayerGui.PointsNotif.Display.Text = "YOU'VE RECEIVED "..Text.." POINTS FROM "..string.upper(Player.Name).."!"
					
					game.Players:FindFirstChild(nameOfUser).PlayerGui.PointsNotif.Display.Visible = true
					Player.PlayerGui.PointsNotif.Display.Visible = true
					wait(2)
					game.Players:FindFirstChild(nameOfUser).PlayerGui.PointsNotif.Display.Visible = false
					Player.PlayerGui.PointsNotif.Display.Visible = false
				else
					Player.PlayerGui.PointsNotif.Display.Text = "YOU CANNOT GIVE POINTS TO YOURSELF!"
					Player.PlayerGui.PointsNotif.Display.Visible = true
					wait(2)
					Player.PlayerGui.PointsNotif.Display.Visible = false
				end
			end
		end
	end)
end)
Editor is loading...
Leave a Comment